public static bool CreateAgency(Agency agency) { try { using (var ctx = new PosContext()) { var found = ctx.Agency.FirstOrDefault(a => a.UserId == agency.UserId); if (found == null) { ctx.Agency.Add(agency); ctx.SaveChanges(); return true; } return false; } } catch (Exception ex) { return false; } }
public bool CreateAgency(RegisterViewModelAgency data, string userid) { var agency = new Agency { UserId = userid, AgencyEmail = data.Agency.AgencyEmail, AgencyName = data.Agency.AgencyName, PostCode = data.Agency.PostCode, AddressLine = data.Agency.AddressLine, Country = data.Agency.Country, City = data.Agency.City, PhoneNumber = data.Agency.PhoneNumber, }; if (AgencyContext.CreateAgency(agency)) return true; return false; }
public ActionResult Edit(Agency agency) { if (ModelState.IsValid) { db.Entry(agency).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(agency); }