Example #1
0
        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;
            }
        }
Example #2
0
        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;

        }
Example #3
0
 public ActionResult Edit(Agency agency)
 {
     if (ModelState.IsValid)
     {
         db.Entry(agency).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(agency);
 }