Beispiel #1
0
        public ActionResult HoldingCreate(Holding holding)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (!_repository.Fetch<Holding>().Any(p => p.Name == holding.Name))
                    {
                        holding.Id = _uniqueId.GetId();
                        holding.Maker = User.Identity.GetUserName();
                        holding.OsysDateTime = DateTime.Now;
                        holding.EditDateTime = DateTime.Now;
                        holding.Status = MyEnums.StatusOptions.Added;
                        holding.Active = MyEnums.Active.Disable;
                        _repository.SaveNew(holding);
                        _logs.LogAudit(User.Identity.GetUserName(), "HoldingCreate_HTTPPOST", Request.UserHostName,
                            "Created Holding :" + holding.Name, "Created");
                    }
                    else
                    {
                        ModelState.AddModelError("", holding.Name + " Already Exists!");
                        return View();
                    }

                }
                return RedirectToAction("HoldingIndex");
            }
            catch (Exception ex)
            {
                _logs.LogError(User.Identity.GetUserName(), "HoldingCreate_HTTPPOST", "Error: " + ex.Message,
                   Request.ServerVariables["REMOTE_ADDR"]);
                return HttpNotFound();
            }
        }
Beispiel #2
0
        public ActionResult HoldingEdit(Holding holding)
        {
            try
            {
                if (ModelState.IsValid)
                {

                    var updateHolding = _repository.Find<Holding>(holding.Id);
                    updateHolding.Maker = User.Identity.GetUserName();
                    updateHolding.EditDateTime = DateTime.Now;
                    updateHolding.Status = MyEnums.StatusOptions.Edited;
                    updateHolding.Active = MyEnums.Active.Disable;
                    updateHolding.Name = holding.Name.Trim();
                    updateHolding.Description = holding.Description;
                    updateHolding.GroupId = holding.GroupId;
                    _repository.SaveUpdate(updateHolding);
                    _logs.LogAudit(User.Identity.GetUserName(), "HoldingEdit_HTTPPOST", Request.UserHostName,
                        "Edited Holding :" + updateHolding.Name, "Edited");

                }
                return RedirectToAction("holdingIndex");
            }
            catch (Exception ex)
            {
                _logs.LogError(User.Identity.GetUserName(), "HoldingEdit_HTTPPOST", "Error: " + ex.Message,
                   Request.ServerVariables["REMOTE_ADDR"]);
                return HttpNotFound();
            }
        }