コード例 #1
0
        public ActionResult AttributeEditorDialog()
        {
            MetadataModel metadata = TempData["Metadata"] as MetadataModel;

            AttributeViewModel attributeModel = metadata.DialogStack.Pop() as AttributeViewModel;

            TempData["Metadata"] = metadata;

            return(PartialView("AttributeEditorDialog", attributeModel));
        }
コード例 #2
0
        public void UpdateQuestionGeneric(FormViewModel _formViewModel, List <QuestionCreateViewModel> _listQuestionCreateViewModel)
        {
            FormViewModel formViewModel = _formViewModel;
            List <QuestionCreateViewModel> listQuestionCreateViewModel = _listQuestionCreateViewModel;

            foreach (var questionCreateViewModel in listQuestionCreateViewModel)
            {
                ElementViewModel elementViewModel = new ElementViewModel
                {
                    Name        = questionCreateViewModel.ElementViewModel.Name,
                    Description = questionCreateViewModel.ElementViewModel.Description
                };
                // elementBL.Create(elementViewModel); // ???

                QuestionViewModel questionViewModel = new QuestionViewModel
                {
                    Name      = questionCreateViewModel.QuestionViewModel.Name,
                    FormId    = formBL.GetId(formViewModel),
                    ElementId = elementBL.GetId(elementViewModel)
                };
                questionBL.Update(questionViewModel);
                int questionId = questionBL.GetId(questionViewModel);

                foreach (var answerViewModel in questionCreateViewModel.AnswerViewModel)
                {
                    AnswerViewModel answerVM = new AnswerViewModel
                    {
                        Name       = answerViewModel.Name,
                        QuestionId = questionId
                    };
                    answerBL.Update(answerVM);
                }

                foreach (var attributeViewModel in questionCreateViewModel.AttributeViewModel)
                {
                    attributeVM = new AttributeViewModel
                    {
                        Name        = attributeViewModel.Name,
                        DisplayName = attributeViewModel.DisplayName,
                        QuestionId  = questionId
                    };
                    attributeBL.Update(attributeVM);
                }

                foreach (var attributeResultViewModel in questionCreateViewModel.AttributeResultViewModel)
                {
                    AttributeResultViewModel attributeResult = new AttributeResultViewModel
                    {
                        Value       = attributeResultViewModel.Value,
                        AttributeId = attributeBL.GetId(attributeVM)
                    };
                    attributeResultBL.Update(attributeResult);
                }
            }
        }
コード例 #3
0
        public ActionResult AttributeEdit()
        {
            AttributeViewModel attributeViewModel = new AttributeViewModel();

            using (ShopDbDataContext db = new ShopDbDataContext())
            {
                attributeViewModel.Attributes = db.Attributes.ToList();
                attributeViewModel.Categories = db.Categories.ToList();
            }
            return(View(attributeViewModel));
        }
コード例 #4
0
 public IActionResult Edit(AttributeViewModel vm)
 {
     try
     {
         return(RedirectToAction("Index", "Attribute"));
     }
     catch
     {
         return(View());
     }
 }
コード例 #5
0
 public MainServiceController(ComputerAccessoriesV2Context db, UserManager <MyUsers> userManager, RoleManager <IdentityRole <int> > roleManager)
 {
     _db        = db;
     CategoryVM = new CategoryViewModel
     {
         listParent = _db.Category.ToList()
     };
     AttributeVM  = new AttributeViewModel();
     _userManager = userManager;
     _roleManager = roleManager;
     //AccountVM.Roles = _db.AspNetRoles.ToList();
 }
コード例 #6
0
        public static string GetDescription(this AttributeViewModel attribute)
        {
            if (attribute == null)
            {
                throw new ArgumentNullException("attribute");
            }

            Template template = GetAttributeTemplate();

            template.Add("attr", attribute);
            return(template.Render().Replace("\\", "\\\\").Replace("\r", "\\r").Replace("\n", "\\n").Replace("\0", "\\0"));
        }
コード例 #7
0
        public JsonResult UpdateAttributeStatus(AttributeViewModel attributeViewModel)
        {
            var attributeModel = new AttributeModel();

            Mapper.Map(attributeViewModel, attributeModel);
            var att = _productService.UpdateAttributeStatus(attributeModel);

            Mapper.Map(att, attributeViewModel);


            return(Json(attributeViewModel, JsonRequestBehavior.AllowGet));
        }
コード例 #8
0
 public IActionResult Edit(AttributeViewModel vm)
 {
     try
     {
         var model = _mapper.Map <Attribute>(vm);
         _unityOfWork.Attribute.Update(model);
         _unityOfWork.Save();
         return(RedirectToAction("Index", "Attribute"));
     }
     catch
     {
         return(View());
     }
 }
コード例 #9
0
        public async Task <IActionResult> AddEditAttribute(long?id, AttributeViewModel attributeViewModel)
        {
            try
            {
                if (attributeViewModel == null)
                {
                    _logger.LogInformation(LogMessageConstant.ItemNotFound, attributeViewModel);
                    return(NotFound());
                }
                if (ModelState.IsValid)
                {
                    bool isNew = !id.HasValue;
                    if (isNew)
                    {
                        var attribute = _mapper.Map <Domain.Attribute>(attributeViewModel);
                        await _uow.Attributes.AddAsync(attribute);

                        _logger.LogInformation(LogMessageConstant.Added, attribute.Name);
                    }
                    else
                    {
                        var attribute = _mapper.Map <Domain.Attribute>(attributeViewModel);
                        await _uow.Attributes.UpdateAsync(id.Value, attribute);

                        _logger.LogInformation(LogMessageConstant.Updated, attribute.Name);
                    }
                }
            }
            catch (DbUpdateConcurrencyException ce)
            {
                var isExist = await _uow.Attributes.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)));
        }
コード例 #10
0
        public static AttributeViewModel AttributeToViewModel(DAL.Models.Attribute attribute, string attributeGroupName)
        {
            string valueType          = EnumHelper.EnumValueTypeToString(attribute.Value);
            var    attributeViewModel = new AttributeViewModel()
            {
                AttributeId        = attribute.Id,
                AttributeName      = attribute.Name,
                CreationDate       = attribute.CreationDate,
                LastModifiedDate   = attribute.LastModifiedDate,
                ValueType          = valueType,
                AttributeGroupName = attributeGroupName
            };

            return(attributeViewModel);
        }
コード例 #11
0
        // GET: Attribute
        public ActionResult Index()
        {
            var attributeList = new AttributeViewModel();

            {
                attributeList.Attribute      = db.Attributes.ToList();
                attributeList.AttributeGroup = db.AttributeGroups.ToList();
            }

            if (attributeList == null)
            {
                return(HttpNotFound());
            }

            return(View(attributeList));
        }
コード例 #12
0
        public JsonResult GetAttributeById(string eAttributeId)
        {
            int attributeId = eAttributeId != "" ? Common.Utility.Helper.Decrypt(eAttributeId) : 0;

            var attributeViewModel = new AttributeViewModel();

            if (attributeId > 0)
            {
                var attribute = _productService.GetAttributeById(attributeId);

                Mapper.Map(attribute, attributeViewModel);
                Mapper.Map(attribute.AttributeCategoryModel, attributeViewModel.AttributeCategories);
            }

            return(Json(new { Attribute = attributeViewModel, Success = true, Message = "Success" }, JsonRequestBehavior.AllowGet));
        }
        public JsonResult GetProductAttribute(int Id)
        {
            var product = _unityOfWork.Product.GetByIdWithAttributes(Id);
            List <AttributeViewModel> attributes = new List <AttributeViewModel>();

            foreach (var attribute in product.ProductAttributes)
            {
                AttributeViewModel model = new AttributeViewModel()
                {
                    ID    = attribute.AttributeID,
                    Name  = _unityOfWork.Attribute.GetById(attribute.AttributeID).Name, //attribute.Attribute.Name,
                    Value = attribute.Value
                };
                attributes.Add(model);
            }
            return(Json(attributes));
        }
    /*==========================================================================================================================
    | METHOD: INVOKE
    \-------------------------------------------------------------------------------------------------------------------------*/
    /// <summary>
    ///   Assembles the view model for the <see cref="TopicReferenceViewComponent"/>.
    /// </summary>
    public IViewComponentResult Invoke(
      EditingTopicViewModel currentTopic,
      TopicReferenceAttributeDescriptorViewModel attribute,
      string htmlFieldPrefix
    ) {

      /*------------------------------------------------------------------------------------------------------------------------
      | Validate parameters
      \-----------------------------------------------------------------------------------------------------------------------*/
      Contract.Requires(currentTopic, nameof(currentTopic));
      Contract.Requires(attribute, nameof(attribute));

      /*------------------------------------------------------------------------------------------------------------------------
      | Set HTML prefix
      \-----------------------------------------------------------------------------------------------------------------------*/
      ViewData.TemplateInfo.HtmlFieldPrefix = htmlFieldPrefix;

      /*------------------------------------------------------------------------------------------------------------------------
      | Set configuration values
      \-----------------------------------------------------------------------------------------------------------------------*/
      //### TODO 6.0.0: Remove hard-coded reference to BaseTopic; this is only needed for backward compatibility with 5.0.0.
      var isBaseTopic           = attribute.Key.Equals("BaseTopic", StringComparison.OrdinalIgnoreCase);
      if (attribute.UseCurrentContentType || isBaseTopic) {
        attribute = attribute with {
          AttributeKey          = "ContentType",
          AttributeValue        = currentTopic.ContentType,
          AutoPostBack          = isBaseTopic? true : attribute.AutoPostBack
        };
      }

      /*------------------------------------------------------------------------------------------------------------------------
      | Establish view model
      \-----------------------------------------------------------------------------------------------------------------------*/
      var viewModel = new AttributeViewModel<TopicReferenceAttributeDescriptorViewModel>(currentTopic, attribute);

      /*------------------------------------------------------------------------------------------------------------------------
      | Return view with view model
      \-----------------------------------------------------------------------------------------------------------------------*/
      return View(viewModel);

    }

  } // Class
コード例 #15
0
        public async Task <IActionResult> AddEditAttribute(long?id)
        {
            AttributeViewModel attributeViewModel = new AttributeViewModel();

            if (id.HasValue)
            {
                var attribute = await _uow.Attributes.GetAsync(id.Value);

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

                attributeViewModel = _mapper.Map <AttributeViewModel>(attribute);
            }

            return(PartialView("~/Areas/Admin/Views/Attribute/_AddEditAttribute.cshtml", attributeViewModel));
        }
コード例 #16
0
        public JsonResult AddEditAttribute(AttributeViewModel attributeViewModel)
        {
            var message = attributeViewModel.AttributeId != null ? "Updated" : "Saved";

            var attributeModel = new AttributeModel();

            Mapper.Map(attributeViewModel, attributeModel);
            Mapper.Map(attributeViewModel.AttributeCategories, attributeModel.AttributeCategoryModel);

            var attribute = _productService.AddEditAttribute(attributeModel);



            Mapper.Map(attribute, attributeViewModel);
            Mapper.Map(attribute.AttributeCategoryModel, attributeViewModel.AttributeCategories);


            return(Json(new { Attribute = attributeViewModel, Success = true, Message = message }, JsonRequestBehavior.AllowGet));
        }
コード例 #17
0
        public async Task <IActionResult> CreateNewAttribute(AttributeViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(NotFound());
            }

            Models.TblAttribute att = new Models.TblAttribute
            {
                AttributeName = model.AttributeName,
                CategoryId    = model.CategoryId,
                CreatedDate   = DateTime.Now
            };

            _db.TblAttribute.Add(att);
            await _db.SaveChangesAsync();

            return(RedirectToAction(nameof(Attributes)));
        }
コード例 #18
0
 public async Task Update(int id, string culture, AttributeViewModel attribute)
 {
     using (var conn = new SqlConnection(_connectionString))
     {
         if (conn.State == System.Data.ConnectionState.Closed)
         {
             conn.Open();
         }
         var paramaters = new DynamicParameters();
         paramaters.Add("@id", id);
         paramaters.Add("@name", attribute.Name);
         paramaters.Add("@sortOrder", attribute.SortOrder);
         paramaters.Add("@backendType", attribute.BackendType);
         paramaters.Add("@isActive", attribute.IsActive);
         paramaters.Add("@hasOption", attribute.HasOption);
         paramaters.Add("@values", attribute.Values);
         await conn.ExecuteAsync("Update_Attribute", paramaters, null, null, System.Data.CommandType.StoredProcedure);
     }
 }
コード例 #19
0
    /*==========================================================================================================================
    | METHOD: INVOKE
    \-------------------------------------------------------------------------------------------------------------------------*/
    /// <summary>
    ///   Assembles the view model for the <see cref="NumberViewComponent"/>.
    /// </summary>
    public IViewComponentResult Invoke(
      EditingTopicViewModel currentTopic,
      NumberAttributeDescriptorViewModel attribute,
      string htmlFieldPrefix
    ) {

      /*------------------------------------------------------------------------------------------------------------------------
      | Set HTML prefix
      \-----------------------------------------------------------------------------------------------------------------------*/
      ViewData.TemplateInfo.HtmlFieldPrefix = htmlFieldPrefix;

      /*------------------------------------------------------------------------------------------------------------------------
      | Establish view model
      \-----------------------------------------------------------------------------------------------------------------------*/
      var viewModel = new AttributeViewModel<NumberAttributeDescriptorViewModel>(currentTopic, attribute);

      /*------------------------------------------------------------------------------------------------------------------------
      | Return view with view model
      \-----------------------------------------------------------------------------------------------------------------------*/
      return View(viewModel);

    }
コード例 #20
0
    /*==========================================================================================================================
    | METHOD: INVOKE
    \-------------------------------------------------------------------------------------------------------------------------*/
    /// <summary>
    ///   Assembles the view model for the <see cref="HtmlViewComponent"/>.
    /// </summary>
    public IViewComponentResult Invoke(
      EditingTopicViewModel currentTopic,
      HtmlAttributeDescriptorViewModel attribute,
      string htmlFieldPrefix
    ) {

      /*------------------------------------------------------------------------------------------------------------------------
      | Validate parameters
      \-----------------------------------------------------------------------------------------------------------------------*/
      Contract.Requires(currentTopic, nameof(currentTopic));
      Contract.Requires(attribute, nameof(attribute));

      /*------------------------------------------------------------------------------------------------------------------------
      | Set HTML prefix
      \-----------------------------------------------------------------------------------------------------------------------*/
      ViewData.TemplateInfo.HtmlFieldPrefix = htmlFieldPrefix;

      /*------------------------------------------------------------------------------------------------------------------------
      | Set configuration values
      \-----------------------------------------------------------------------------------------------------------------------*/
      if (attribute.Height is null || attribute.Height is 0 && attribute.Rows is not null) {
        attribute = attribute with {
          Height = attribute.Rows * 20
        };
      }

      /*------------------------------------------------------------------------------------------------------------------------
      | Establish view model
      \-----------------------------------------------------------------------------------------------------------------------*/
      var viewModel = new AttributeViewModel<HtmlAttributeDescriptorViewModel>(currentTopic, attribute);

      /*------------------------------------------------------------------------------------------------------------------------
      | Return view with view model
      \-----------------------------------------------------------------------------------------------------------------------*/
      return View(viewModel);

    }

  } // Class
コード例 #21
0
 public async Task Update(int id, [FromBody] AttributeViewModel attribute)
 {
     await _attributeRepository.Update(id, CultureInfo.CurrentCulture.Name, attribute);
 }
コード例 #22
0
 public ActionResult AddNewAttributes(AttributeViewModel model)
 {
     return(View("../Product/Attributes"));
 }
コード例 #23
0
        public async Task <IActionResult> Add(AttributeViewModel model)
        {
            await _attributeService.AddAsync(model);

            return(RedirectToAction("Index"));
        }
コード例 #24
0
    /*==========================================================================================================================
    | METHOD: INVOKE
    \-------------------------------------------------------------------------------------------------------------------------*/
    /// <summary>
    ///   Assembles the view model for the <see cref="ReflexiveViewComponent"/>.
    /// </summary>
    public async Task<IViewComponentResult> InvokeAsync(
      EditingTopicViewModel currentTopic,
      ReflexiveAttributeDescriptorViewModel attribute,
      string htmlFieldPrefix
    ) {

      /*------------------------------------------------------------------------------------------------------------------------
      | Validate parameters
      \-----------------------------------------------------------------------------------------------------------------------*/
      Contract.Requires(currentTopic, nameof(currentTopic));
      Contract.Requires(attribute, nameof(attribute));

      /*------------------------------------------------------------------------------------------------------------------------
      | Set HTML prefix
      \-----------------------------------------------------------------------------------------------------------------------*/
      ViewData.TemplateInfo.HtmlFieldPrefix = htmlFieldPrefix;

      /*------------------------------------------------------------------------------------------------------------------------
      | Establish snapshot of previously saved attribute descriptor
      \-----------------------------------------------------------------------------------------------------------------------*/
      var topic                 = _topicRepository.Load(currentTopic.UniqueKey);
      var reflexiveViewModel    = (AttributeDescriptorViewModel?)null;

      if (topic?.ContentType.EndsWith("AttributeDescriptor", StringComparison.OrdinalIgnoreCase)?? false) {
        reflexiveViewModel      = (AttributeDescriptorViewModel?)await _topicMappingService.MapAsync(topic).ConfigureAwait(false);
      }

      if (reflexiveViewModel is null) {
        reflexiveViewModel      = new();
      }

      /*------------------------------------------------------------------------------------------------------------------------
      | Establish hybrid view model
      >-------------------------------------------------------------------------------------------------------------------------
      | The ParentAttributeDescriptor will be of the target type expected for the view component that will be executed. But it
      | should use the core AttributeDescriptor attributes of the current attribute, so it shows up in the same location with
      | the same title and description as defined for the ReflexiveAttributeDescriptorViewModel.
      \-----------------------------------------------------------------------------------------------------------------------*/
      reflexiveViewModel        = reflexiveViewModel with {
        Key                     = attribute.Key,
        Description             = attribute.Description,
        DisplayGroup            = attribute.DisplayGroup,
        DefaultValue            = attribute.DefaultValue,
        IsRequired              = attribute.IsRequired,
        SortOrder               = attribute.SortOrder,
        Title                   = attribute.Title
      };

      /*------------------------------------------------------------------------------------------------------------------------
      | Establish view model
      \-----------------------------------------------------------------------------------------------------------------------*/
      var viewModel = new AttributeViewModel<AttributeDescriptorViewModel>(currentTopic, reflexiveViewModel);

      /*------------------------------------------------------------------------------------------------------------------------
      | Return view with view model
      \-----------------------------------------------------------------------------------------------------------------------*/
      return View(viewModel);

    }

  } // Class
コード例 #25
0
        public ActionResult ViewAttributes()
        {
            AttributeViewModel model = new AttributeViewModel();

            return(View("../Product/Attributes", model));
        }
コード例 #26
0
 public AttributeView()
 {
     InitializeComponent();
     DataContext = new AttributeViewModel();
 }
コード例 #27
0
        public JsonResult AddEditAttribute(AttributeViewModel attributeViewModel)
        {
            var message = attributeViewModel.AttributeId != null ? "Updated" : "Saved";

            var attributeModel = new AttributeModel();
            Mapper.Map(attributeViewModel, attributeModel);
            Mapper.Map(attributeViewModel.AttributeCategories, attributeModel.AttributeCategoryModel);

            var attribute = _productService.AddEditAttribute(attributeModel);

            Mapper.Map(attribute, attributeViewModel);
            Mapper.Map(attribute.AttributeCategoryModel, attributeViewModel.AttributeCategories);

            return Json(new { Attribute = attributeViewModel, Success = true, Message = message }, JsonRequestBehavior.AllowGet);
        }
コード例 #28
0
        /// <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(Attribute model, AttributeViewModel viewModel, Person currentPerson = null, bool loadAttributes = true)
        {
            var attributeCache = AttributeCache.Get(model.Id);

            viewModel.FieldTypeGuid   = FieldTypeCache.Get(attributeCache.FieldTypeId).Guid;
            viewModel.CategoryGuids   = attributeCache.Categories.Select(c => c.Guid).ToArray();
            viewModel.QualifierValues = attributeCache.QualifierValues.ToDictionary(kvp => kvp.Key, kvp => new ViewModel.NonEntities.AttributeConfigurationValue
            {
                Name        = kvp.Value.Name,
                Value       = kvp.Value.Value,
                Description = kvp.Value.Description
            });
        }
コード例 #29
0
        public JsonResult UpdateAttributeStatus(AttributeViewModel attributeViewModel)
        {
            var attributeModel = new AttributeModel();

            Mapper.Map(attributeViewModel, attributeModel);
            var att = _productService.UpdateAttributeStatus(attributeModel);
            Mapper.Map(att, attributeViewModel);

            return Json(attributeViewModel, JsonRequestBehavior.AllowGet);
        }
コード例 #30
0
        public JsonResult GetAttributeById(string eAttributeId)
        {
            int attributeId = eAttributeId != "" ? Common.Utility.Helper.Decrypt(eAttributeId) : 0;

            var attributeViewModel = new AttributeViewModel();
            if (attributeId > 0)
            {
                var attribute = _productService.GetAttributeById(attributeId);

                Mapper.Map(attribute, attributeViewModel);
                Mapper.Map(attribute.AttributeCategoryModel, attributeViewModel.AttributeCategories);
            }

            return Json(new { Attribute = attributeViewModel, Success = true, Message = "Success" }, JsonRequestBehavior.AllowGet);
        }
コード例 #31
0
        public ActionResult Edit(int Id)
        {
            AttributeViewModel attributeViewModel = Mapper.Map <App.Domain.Entities.Attribute.Attribute, AttributeViewModel>(this._attributeService.GetById(Id));

            return(base.View(attributeViewModel));
        }
コード例 #32
0
 public async Task AddAttribute([FromBody] AttributeViewModel attribute)
 {
     await _attributeRepository.Add(CultureInfo.CurrentCulture.Name, attribute);
 }