Exemple #1
0
        public ResponseViewModel Add(VehicleTypeDto vehicleTypeDto)
        {
            var response = new ResponseViewModel();

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

                    return(response);
                }
            }

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

                    return(response);
                }
            }

            var vehicleTpye = new VehicleType()
            {
                Name       = vehicleTypeDto.Name,
                CreateDate = vehicleTypeDto.CreateDate,
                CreatedBy  = vehicleTypeDto.CreatedBy,
                ModifyDate = vehicleTypeDto.ModifyDate,
                ModifiedBy = vehicleTypeDto.ModifiedBy
            };

            _vehicleTypeDal.Add(vehicleTpye);
            var saving = _vehicleTypeDal.SaveChanges();

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

                return(response);
            }

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

            return(response);
        }
 //[SecuredOperation("user")]
 //[CacheRemoveAspect("IVehicleTypeService.Get")]
 public IResult Add(VehicleType vehicleType)
 {
     _vehicleTypeDal.Add(vehicleType);
     return(new SuccessResult(Messages.TypeAdded));
 }