public void AddOffersSetup(Models.OffersSetup OffersSetup) { try { var db = new Context.ConnectionStringsContext(); if (!db.OffersSetup.Any(m => m.MicrosoftOfferId == OffersSetup.MicrosoftOfferId)) { OffersSetup.CreatedDate = DateTime.Now; OffersSetup.AppliedDate = DateTime.Now; OffersSetup.Status = true; db.OffersSetup.Add(OffersSetup); } else { var _o = db.OffersSetup.Where(m => m.MicrosoftOfferId == OffersSetup.MicrosoftOfferId).SingleOrDefault(); _o.Features = OffersSetup.Features; _o.Price = OffersSetup.Price; _o.SubTitle = OffersSetup.SubTitle; _o.Summary = OffersSetup.Summary; _o.Title = OffersSetup.Title; } db.SaveChanges(); } catch { } }
public async Task <ActionResult> AddOrUpdate(string Offerid) { MicrosoftOffer microsoftOffers = await ApplicationDomain.Instance.OffersRepository.RetrieveMicrosoftOfferByIdAsync(Offerid).ConfigureAwait(false); OffersSetup offersSetup = new Models.OffersSetup(); ViewModel.OffersSetup.OffersSetup _o = new ViewModel.OffersSetup.OffersSetup(); offersSetup = _o.GetOfferByMicrosoftOfferId(Offerid); if (offersSetup.MicrosoftOfferId == null) { offersSetup.MicrosoftOfferId = Offerid; offersSetup.Title = microsoftOffers.Offer.Name; } Models.OffersSetupRepository rep = new OffersSetupRepository(); rep.MicrosoftOffer = microsoftOffers; rep.OffersSetup = offersSetup; return(View(rep)); }