public ActionResult SubmitApp(FormCollection fc) { try { if (Session["userid"] != null) { if (string.IsNullOrEmpty(fc["actualprice"]) || string.IsNullOrEmpty(fc["offerprice"]) || string.IsNullOrEmpty(fc["datepickerstart"]) || string.IsNullOrEmpty(fc["datepickerend"]) || string.IsNullOrEmpty(fc["link"]) || string.IsNullOrEmpty(fc["title"])) { ViewBag.Success = "Please fill all the fields"; return View(); } else { if (ModelState.IsValid) { Submit_App sa = new Submit_App(); sa.App_type = fc["Fapp"]; sa.Actual_Price = Decimal.Parse(fc["actualprice"]); sa.offerprice = Decimal.Parse(fc["offerprice"]); sa.App_Description = fc["description"]; sa.App_Title = fc["title"]; if (fc["link"].StartsWith("https://")) { sa.iTunes_Link = fc["link"]; } else { sa.iTunes_Link = "https://" + fc["link"]; } sa.UserID = (long)Session["userid"]; sa.StartDate = DateTime.ParseExact(@fc["datepickerstart"], "dd-MM-yyyy HH:mm", CultureInfo.InvariantCulture); sa.EndDate = DateTime.ParseExact(@fc["datepickerend"], "dd-MM-yyyy HH:mm", CultureInfo.InvariantCulture); sa.downloads_count = 0; if (sa.StartDate > sa.EndDate) { ViewBag.success = "End Date should be higher than Start Date"; return View(); } var id = Session["userid"]; var stdate = DateTime.ParseExact((@fc["datepickerstart"]), "dd-MM-yyyy HH:mm", CultureInfo.InvariantCulture); var enddate = DateTime.ParseExact((@fc["datepickerend"]), "dd-MM-yyyy HH:mm", CultureInfo.InvariantCulture); var contents = from u in entity.Submit_App where ((u.StartDate == stdate && u.EndDate == enddate) || (u.StartDate <= stdate && u.EndDate >= enddate) || (u.StartDate >= stdate && u.EndDate <= enddate)) //&& u.UserID == (long)id select new { u.EndDate, u.StartDate }; int count = 0; //s = contents.Count(); foreach (var item in contents) { //if ((item.StartDate == stdate && item.EndDate == enddate) || (item.StartDate <= stdate && item.EndDate >= enddate) || (item.StartDate >= stdate && item.EndDate <= enddate)) //{ count++; //} } if (count < 2) { string icons=save(Request.Files["icon"], "~/icons"); string images=save(Request.Files["img"], "~/images"); if ((images==null || images=="") || (icons==null || icons=="")) { ViewBag.success = "Please Upload App Icon/Image"; return View(); } else { sa.App_Icon = "/icons/" + icons; sa.App_Image = "/images/" + images; entity.AddToSubmit_App(sa); entity.SaveChanges(); Login_Table app = entity.Login_Table.ToList().Where(x => x.UserID == (long)Session["userid"]).First(); app.Apps_Published = app.Apps_Published + 1; entity.SaveChanges(); ViewBag.success = "App published succesfully"; return View(); } } else { ViewBag.success = "2 Apps registered on your selected date choose another date"; return View(); } } } } else { return RedirectToAction("Login", "Login"); } return View(); } catch(Exception ex) { ViewBag.success = ex.Message.ToString(); return View(); } //} }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)