예제 #1
0
        public async Task <TypeOfLossViewModel> Find(int id)
        {
            try
            {
                TypeOfLossViewModel lossTypes = await this.BusinessLayer.Find(id);

                return(lossTypes);
            }
            catch (Exception ex)
            {
                this.ExceptionLogger.Log(LogLevel.Error, ex);
                throw ex;
            }
        }
예제 #2
0
        public async Task <TypeOfLossViewModel> Create(TypeOfLossViewModel model)
        {
            var typeOfLoss = this.TypeOfLossRepository.Add(ViewModelToEntityMapper.Map(model));

            if (typeOfLoss.Id > 0)
            {
                model.LossTypeId = typeOfLoss.Id;
            }
            else
            {
                model.HasError = true;
            }

            return(model);
        }
예제 #3
0
        public async Task <TypeOfLossViewModel> Update(TypeOfLossViewModel lTypedata)
        {
            try
            {
                lTypedata.LastModifiedBy = User.Identity.GetUserId();
                lTypedata.LastModifiedOn = DateTime.Now;
                lTypedata.IsActive       = true;

                return(await this.BusinessLayer.Update(lTypedata));
            }
            catch (Exception ex)
            {
                this.ExceptionLogger.Log(LogLevel.Error, ex);
                throw ex;
            }
        }
예제 #4
0
        public static TypeOfLoss Map(TypeOfLossViewModel viewModel, TypeOfLoss entity)
        {
            if (viewModel == null || entity == null)
            {
                return(null);
            }

            entity.Id               = viewModel.LossTypeId;
            entity.Name             = viewModel.LossTypeName;
            entity.SortOrder        = viewModel.SortOrder;
            entity.LastModifiedBy   = viewModel.LastModifiedBy;
            entity.LastModifiedDate = viewModel.LastModifiedOn;
            entity.IsActive         = viewModel.IsActive;

            return(entity);
        }
예제 #5
0
        public static TypeOfLoss Map(TypeOfLossViewModel viewModel)
        {
            if (viewModel == null)
            {
                return(null);
            }

            return(new TypeOfLoss
            {
                Name = viewModel.LossTypeName,
                Description = null,
                SortOrder = viewModel.SortOrder,
                CreatedBy = viewModel.CreatedBy,
                CreatedDate = viewModel.CreatedOn,
                LastModifiedBy = viewModel.LastModifiedBy,
                LastModifiedDate = viewModel.LastModifiedOn,
                IsActive = viewModel.IsActive,
            });
        }
예제 #6
0
        public async Task <TypeOfLossViewModel> Update(TypeOfLossViewModel viewModel)
        {
            var typeOfLossInfo = this.TypeOfLossRepository.Find(viewModel.LossTypeId);

            if (typeOfLossInfo != null)
            {
                var lastModifiedDate = typeOfLossInfo.LastModifiedDate;
                typeOfLossInfo = this.TypeOfLossRepository.Update(ViewModelToEntityMapper.Map(viewModel, typeOfLossInfo));

                if (lastModifiedDate < typeOfLossInfo.LastModifiedDate)
                {
                    return(viewModel);
                }
                else
                {
                    viewModel.HasError = true;
                }
            }

            return(viewModel);
        }