Exemple #1
0
        private async Task <BaseResult> Update(Domain.Attributes.Attribute Attribute, int updateBy = 0, string updateByUserName = "")
        {
            var result = new BaseResult()
            {
                Result = Result.Success
            };
            var AttributeForUpdate = _attributeRepository.Query().FirstOrDefault(p => p.Id == Attribute.Id);

            if (AttributeForUpdate == null || Attribute.Id <= 0)
            {
                result.Result  = Result.Failed;
                result.Message = "Không tìm thấy sản phẩm yêu cầu!";
                return(result);
            }
            try
            {
                AttributeForUpdate = Attribute.ToAttribute(AttributeForUpdate);

                //Cập nhật thông tin chung của thực thể
                AttributeForUpdate = AttributeForUpdate.UpdateCommonInt(updateBy, updateByUserName);

                await _attributeRepository.UpdateAsync(AttributeForUpdate);
            }
            catch (Exception e)
            {
                result.Result  = Result.SystemError;
                result.Message = e.ToString();
            }
            return(result);
        }
Exemple #2
0
        private async Task <BaseResult> Create(Domain.Attributes.Attribute Attribute)
        {
            var result = new BaseResult();

            Attribute.Name = Attribute.Name.Trim();
            try
            {
                await _attributeRepository.InsertAsync(Attribute);
            }
            catch (Exception e)
            {
                result.Result  = Result.SystemError;
                result.Message = e.ToString();
            }
            return(result);
        }