예제 #1
0
        public ActionResult Create(AttributeValueViewModel attributeValue, string ReturnUrl)
        {
            ActionResult action;

            try
            {
                if (!base.ModelState.IsValid)
                {
                    base.ModelState.AddModelError("", MessageUI.ErrorMessage);
                    return(base.View(attributeValue));
                }
                else
                {
                    AttributeValue attributeValue1 = Mapper.Map <AttributeValueViewModel, AttributeValue>(attributeValue);
                    this._attributeValueService.Create(attributeValue1);
                    base.Response.Cookies.Add(new HttpCookie("system_message", string.Format(MessageUI.CreateSuccess, FormUI.AttributeValue)));
                    if (!base.Url.IsLocalUrl(ReturnUrl) || ReturnUrl.Length <= 1 || !ReturnUrl.StartsWith("/") || ReturnUrl.StartsWith("//") || ReturnUrl.StartsWith("/\\"))
                    {
                        action = base.RedirectToAction("Index");
                    }
                    else
                    {
                        action = this.Redirect(ReturnUrl);
                    }
                }
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
                ExtentionUtils.Log(string.Concat("District.Create: ", exception.Message));
                return(base.View(attributeValue));
            }
            return(action);
        }
예제 #2
0
        public ActionResult Create(AttributeValueViewModel attributeValue, string returnUrl)
        {
            ActionResult action;

            try
            {
                if (!ModelState.IsValid)
                {
                    ModelState.AddModelError("", MessageUI.ErrorMessage);
                    return(View(attributeValue));
                }

                var attributeValue1 = Mapper.Map <AttributeValueViewModel, AttributeValue>(attributeValue);
                _attributeValueService.Create(attributeValue1);
                Response.Cookies.Add(new HttpCookie("system_message", string.Format(MessageUI.CreateSuccess, FormUI.AttributeValue)));
                if (!Url.IsLocalUrl(returnUrl) || returnUrl.Length <= 1 || !returnUrl.StartsWith("/") || returnUrl.StartsWith("//") || returnUrl.StartsWith("/\\"))
                {
                    action = RedirectToAction("Index");
                }
                else
                {
                    action = Redirect(returnUrl);
                }
            }
            catch (Exception exception1)
            {
                var exception = exception1;
                LogText.Log(string.Concat("District.Create: ", exception.Message));
                return(View(attributeValue));
            }
            return(action);
        }
예제 #3
0
        public ActionResult SaveData(IList <AttributeValueViewModel> attributeValueViewModel)
        {
            try
            {
                int    index  = 0;
                String result = String.Empty;
                AttributeValueViewModel attribValVM = new AttributeValueViewModel();

                index = attribValVM.SaveData(attributeValueViewModel);
                if (index > 0)
                {
                    result = "1";
                }
                else
                {
                    result = "0";
                }

                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                errorlogviewmodel = new ErrorLogViewModel();
                errorlogviewmodel.LogError(ex);
                return(View("Error"));
            }
        }
예제 #4
0
 public AttributeValue ToAttributeValue(AttributeValueViewModel attributeValue)
 {
     return(new AttributeValue()
     {
         Id = attributeValue.Id,
         AttributeTypeId = attributeValue.AttributeType != null ? attributeValue.AttributeType.Id : attributeValue.AttributeTypeId,
         Value = attributeValue.Value
     });
 }
예제 #5
0
        public async Task <IActionResult> AddEditAttributeValue(long?id, AttributeValueViewModel attributeValueViewModel)
        {
            try
            {
                if (attributeValueViewModel == null)
                {
                    _logger.LogInformation(LogMessageConstant.ItemNotFound, attributeValueViewModel);
                    return(NotFound());
                }
                if (ModelState.IsValid)
                {
                    bool isNew = !id.HasValue;
                    if (isNew)
                    {
                        var attributeValue = _mapper.Map <AttributeValue>(attributeValueViewModel);
                        await _uow.AttributeValues.AddAsync(attributeValue);

                        _logger.LogInformation(LogMessageConstant.Added, attributeValue.Name);
                    }
                    else
                    {
                        var attributeValue = _mapper.Map <AttributeValue>(attributeValueViewModel);
                        await _uow.AttributeValues.UpdateAsync(id.Value, attributeValue);

                        _logger.LogInformation(LogMessageConstant.Updated, attributeValue.Name);
                    }
                }
            }
            catch (DbUpdateConcurrencyException ce)
            {
                var isExist = await _uow.AttributeValues.GetAsync(id.Value);

                if (isExist == null)
                {
                    _logger.LogWarning(LogMessageConstant.IdNotFound, id);
                    return(NotFound());
                }
                else
                {
                    _logger.LogError(ce.Message, id);
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message, ex.StackTrace);
            }

            return(RedirectToAction(nameof(Index), new { id = attributeValueViewModel.AttributeId }));
        }
예제 #6
0
 public ActionResult GetValues(int attributeId)
 {
     try
     {
         AttributeValueViewModel attribValVM = new AttributeValueViewModel();
         attribValVM.GetAttributeValues(attributeId);
         return(Json(attribValVM.LstAttribVal, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         errorlogviewmodel = new ErrorLogViewModel();
         errorlogviewmodel.LogError(ex);
         return(View("Error"));
     }
 }
예제 #7
0
        public async Task <IActionResult> AddEditAttributeValue(long?id, long attributeId)
        {
            AttributeValueViewModel attributeValueViewModel = new AttributeValueViewModel
            {
                AttributeId = attributeId
            };

            if (id.HasValue)
            {
                var attributeValue = await _uow.AttributeValues.GetAsync(id.Value);

                if (attributeValue == null)
                {
                    _logger.LogInformation(LogMessageConstant.ItemNotFound, attributeValueViewModel);
                    return(NotFound());
                }

                attributeValueViewModel = _mapper.Map <AttributeValueViewModel>(attributeValue);
            }

            return(PartialView("~/Areas/Admin/Views/AttributeValue/_AddEditAttributeValue.cshtml", attributeValueViewModel));
        }
예제 #8
0
        public ActionResult Index(AttributeValueViewModel attribValviewmodel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    attribValviewmodel.AttributeDesc = attribValviewmodel.AttributeDesc.Trim();

                    AttributeValueViewModel attribValVM = new AttributeValueViewModel();
                    TempData["daId"] = attribValVM.DaId;

                    return(RedirectToAction("Index", "AttributeValue"));
                }

                return(View(attribValviewmodel));
            }
            catch (Exception ex)
            {
                errorlogviewmodel = new ErrorLogViewModel();
                errorlogviewmodel.LogError(ex);
                return(View("Error"));
            }
        }
예제 #9
0
        public ActionResult Index(int?id)
        {
            try
            {
                string urlPart = @"/AttributeList/";
                if (System.Web.HttpContext.Current.Request.UrlReferrer.ToString().IndexOf(urlPart) > 0)
                {
                    Session["PreviousURL"] = System.Web.HttpContext.Current.Request.UrlReferrer;
                }

                AttributeValueViewModel attribValVM = new AttributeValueViewModel();

                if (id == null)
                {
                    id = (int)TempData["daId"];
                }
                attribValVM.GetAttributeList(id);
                //attribValVM.GetAttributeValues(id);

                CommonFunctions comfuns = new CommonFunctions();

                var da = comfuns.FindDA((int)id);
                attribValVM.DaId     = (int)id;
                attribValVM.daName   = da.DAName;
                attribValVM.ModuleId = da.ModuleId;
                TempData["daId"]     = attribValVM.DaId;

                return(View(attribValVM));
            }
            catch (Exception ex)
            {
                errorlogviewmodel = new ErrorLogViewModel();
                errorlogviewmodel.LogError(ex);
                return(View("Error"));
            }
        }
예제 #10
0
        public ActionResult Edit(int Id)
        {
            AttributeValueViewModel attributeValueViewModel = Mapper.Map <AttributeValue, AttributeValueViewModel>(this._attributeValueService.GetById(Id));

            return(base.View(attributeValueViewModel));
        }
 /// <summary>
 /// Applies the additional properties and security to view model.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="viewModel">The view model.</param>
 /// <param name="currentPerson">The current person.</param>
 /// <param name="loadAttributes">if set to <c>true</c> [load attributes].</param>
 public override void ApplyAdditionalPropertiesAndSecurityToViewModel(AttributeValue model, AttributeValueViewModel viewModel, Person currentPerson = null, bool loadAttributes = true)
 {
     viewModel.Attribute = AttributeCache.Get(model.AttributeId).ToViewModel();
 }