Пример #1
0
        public ActionResult New(CategoryViewModel model)
        {
            // Add it to http context
            try
            {
                var command = new CategoryCommand()
                {
                    Name             = model.Name,
                    Code             = model.Code,
                    CRMCode          = model.CRMCode,
                    Type             = model.Type,
                    ShortDescription = model.ShortDescription,
                    LongDescription  = model.LongDescription,
                    SortOrder        = model.SortOrder,
                    Status           = model.Status,
                    Environment      = this.Environment,
                    UserToken        = this.UserToken,
                    SessionId        = this.SessionId
                };

                var response = _metadataServiceClient.CreateCategory(command);

                model.CategoryId = response.CategoryId;

                if (response.Errors.Any())
                {
                    model.Errors = response.Errors;
                }
            }
            catch (Exception ex)
            {
                Log(LogMode.Error, "There is an error while creating a category!", ex);

                model.Errors.Add(ex.Message);

                return(RedirectToAction("Details", new { id = model.CategoryId }));
            }

            return(RedirectToAction("Details", new { id = model.CategoryId }));
        }