示例#1
0
        public ResponseViewModel Add(MaintenanceHistoryDto maintenanceHistoryDto)
        {
            var response = new ResponseViewModel();

            var maintenanceId = IsMaintenanceHave(maintenanceHistoryDto.MaintenanceId);

            if (!maintenanceId)
            {
                response.IsSuccess = false;
                response.Message   = "MaintenanceId Maintenance tablosunda bulunamadı";

                return(response);
            }

            var actionTypeId = IsActionTypeHave(maintenanceHistoryDto.ActionTypeId);

            if (!actionTypeId)
            {
                response.IsSuccess = false;
                response.Message   = "actionTypeId ActionType tablosunda bulunamadı";

                return(response);
            }
            if (maintenanceHistoryDto.CreatedBy != null)
            {
                var createdBy = IsUserHave((int)maintenanceHistoryDto.CreatedBy);
                if (!createdBy)
                {
                    response.IsSuccess = false;
                    response.Message   = "createdBy User tablosunda bulunamadı";

                    return(response);
                }
            }

            if (maintenanceHistoryDto.ModifiedBy != null)
            {
                var modifiedBy = IsUserHave((int)maintenanceHistoryDto.ModifiedBy);
                if (!modifiedBy)
                {
                    response.IsSuccess = false;
                    response.Message   = "modifiedBy User tablosunda bulunamadı";

                    return(response);
                }
            }

            var maintenanceHistory = new MaintenanceHistory()
            {
                MaintenanceId = maintenanceHistoryDto.MaintenanceId,
                ActionTypeId  = maintenanceHistoryDto.ActionTypeId,
                CreateDate    = DateTime.Now,
                CreatedBy     = maintenanceHistoryDto.CreatedBy,
                ModifyDate    = maintenanceHistoryDto.ModifyDate,
                ModifiedBy    = maintenanceHistoryDto.ModifiedBy,
                Text          = maintenanceHistoryDto.Text,
            };

            _maintenanceHistoryDal.Add(maintenanceHistory);

            var saving = _maintenanceHistoryDal.SaveChanges();

            if (!saving)
            {
                response.IsSuccess = false;
                response.Message   = "MaintenanceHistory ekleme işlemi sırasında hata oluştu.";

                return(response);
            }

            response.Data = "Id : " + maintenanceHistory.Id;

            return(response);
        }
示例#2
0
 public IResult Add(MaintenanceHistory maintenanceHistory)
 {
     _maintenanceHistoryDal.Add(maintenanceHistory);
     return(new SuccessResult(Messages.Added));
 }