public string SaveHappyHoursDates(HappyHoursDatesModel model) { try { var cultureSource = new CultureInfo("en-US", false); DateTime StartTime = DateTime.Parse(model.TimeStart, cultureSource); TimeSpan starttime = StartTime.TimeOfDay; DateTime EndTime = DateTime.Parse(model.TimeEnd, cultureSource); TimeSpan endtime = EndTime.TimeOfDay; int Max = SaveOfferType(model.OfferType); Nibs_HappyHoursDates tb = new Nibs_HappyHoursDates(); tb.Discount = model.Discount; DateTime enddate = (Convert.ToDateTime(model.EndDate)).Date; tb.EndDate = enddate; tb.FreeItemId = model.FreeItemId; tb.HHOfferType = model.HHOfferType; tb.OfferId = Max; DateTime startdate = (Convert.ToDateTime(model.StartDate)).Date; tb.StartDate = startdate; tb.TimeEnd = endtime; tb.TimeStart = starttime; tb.ItemIndex = model.ItemIndex; _entities.Nibs_HappyHoursDates.Add(tb); _entities.SaveChanges(); return("record saved successfully.."); } catch { return("something wrong try again !"); } }
public ActionResult SaveHappyHoursDates(HappyHoursDatesModel model) { var Data = happy.SaveHappyHoursDates(model); TempData["result"] = Data; return(RedirectToAction("Index")); }