Beispiel #1
0
        public ActionResult Add(CompanyModel companyModel)
        {
            try
            {
                companyModel.AddCompany();
                TempData["message"]   = "Successfully added Company.";
                TempData["alertType"] = "success";
            }

            catch (Exception e)
            {
                TempData["message"]   = "Failed to Add Company.";
                TempData["alertType"] = "danger";
                Console.Write(e.Message);
            }

            return(View(companyModel));
        }
Beispiel #2
0
        public ActionResult CompanyManage([Bind(Include = "Id,Name,Address,Url,Tel")] CompanyModel model)
        {
            //创建删除日志
            LogModel logModel = new LogModel();

            logModel.Name = User.Identity.Name;
            logModel.Date = DateTime.Now;


            if (model.Id == 0)
            {
                model.AddCompany(model);

                logModel.Content = "AddCompany";
                try
                {
                    logModel.AddLog(logModel);
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("", "日志创建失败");
                }
                HttpContext.Response.Write("<script>alert('保存成功!')</script>");
                return(View("CompanyManage"));
            }
            else
            {
                model.UpdateCompany(model);

                logModel.Content = "UpdateCompany";
                try
                {
                    logModel.AddLog(logModel);
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("", "日志创建失败");
                }
                return(RedirectToAction("Index", "Company"));
            }
        }