public DbEntityValidationException AddOrUpdateCateringEnterprise(CateringCompany model, List <string> propertyNames)
        {
            using (var repo = Repo <CateringCompanyRepository>())
            {
                try
                {
                    if (model.Id == Guid.Empty)
                    {
                        var dbModel = repo.CreateDefaultModel();
                        foreach (var propertyName in propertyNames)
                        {
                            dbModel.GetType().GetProperty(propertyName).SetValue(dbModel, model.GetType().GetProperty(propertyName).GetValue(model));
                        }
                        repo.AddOrUpdateDoCommit(dbModel);
                    }
                    else
                    {
                        repo.PartialUpdateDoCommit(model, propertyNames);
                    }
                }
                catch (DbEntityValidationException ex)
                {
                    return(ex);
                }
            }

            return(null);
        }
Ejemplo n.º 2
0
        public ActionResult EditCateringEnterprise(CateringCompany model)
        {
            var propertyNames = Request.Form.AllKeys.Where(field => field != "Id" && field != "X-Requested-With").ToList();

            var exception = ProcessInvoke <CateringEnterpriseProcess>().AddOrUpdateCateringEnterprise(model, propertyNames);

            if (exception != null)
            {
                return(View(model));
            }

            return(RedirectToAction("SubmitSuccess", "Common",
                                    new { targetAction = "EditCateringEnterprise", targetcontroller = "Management", target = "slide-up-content", postform = "catering" }));
        }