public string CreateNewCarClass(CarClassEntity cce)
        {
            var classAlreadyExistsInRegion =
                CarClassEntityCheck.DoesClassExistForCountry(DataContext, cce.CarClassName,
                                                             cce.CountryId);

            if (classAlreadyExistsInRegion)
            {
                return(CarClassEntityCheck.ClassAlreadyExistsForCountry);
            }


            var newCarClassEnitiy = new CAR_CLASS
            {
                IsActive       = true,
                car_class1     = cce.CarClassName,
                car_segment_id = cce.CarSegmentId
            };

            DataContext.CAR_CLASSes.InsertOnSubmit(newCarClassEnitiy);

            var returned = SubmitDbChanges();

            return(returned);
        }
Пример #2
0
        public CarClass ReadCarClassById(long idCarClass)
        {
            CarClassEntity carClassEntity = new CarClassEntity();

            carClassEntity = dbCtx.CarClassEntity.Where(c => c.IdCarClass == idCarClass).FirstOrDefault();
            IMapper mapper = _carClassConfig.CreateMapper();

            return(mapper.Map <CarClassEntity, CarClass>(carClassEntity));
        }
Пример #3
0
 public CarClassEntity UpdateCarClass(CarClassEntity carClass)
 {
     try {
         return(_carClassEngine.UpdateCarClass(carClass));
     } catch (Exception e) {
         _exceptionHandlerLogic.LogExceptionAsync(e);
         throw e;
     }
 }
 public CarClassEntity AddCarClass(CarClassEntity carClass)
 {
     using (var context = DataAccess.GetDBContext) {
         var carClassElement = Mapper.Map <CarClasses>(carClass);
         context.CarClasses.Add(carClassElement);
         context.SaveChanges();
         return(Mapper.Map <CarClassEntity>(carClassElement));
     }
 }
 public CarClassEntity UpdateCarClass(CarClassEntity carClass)
 {
     using (var context = DataAccess.GetDBContext) {
         var carClassElement = context.CarClasses
                               .Where(c => c.CarClassId == carClass.CarClassId)
                               .FirstOrDefault();
         if (carClassElement == null)
         {
             return(null);
         }
         carClassElement.Name            = carClass.Name;
         carClassElement.DailyPrice      = carClass.DailyPrice;
         carClassElement.DelayDailyPrice = carClass.DelayDailyPrice;
         carClassElement.ModifiedDate    = DateTime.Now;
         context.SaveChanges();
         return(Mapper.Map <CarClassEntity>(carClassElement));
     }
 }
Пример #6
0
        protected void btnSavePopup_Click(object sender, EventArgs e)
        {
            var cce = new CarClassEntity
            {
                Id           = int.Parse(hfCarClassId.Value),
                CarClassName = tbCarClass.Text,
                Active       = cbActive.Checked
            };

            if (ddlCarSegment.Visible)
            {
                if (ddlCarSegment.SelectedValue == string.Empty)
                {
                    return;
                }
                cce.CarSegmentId = int.Parse(ddlCarSegment.SelectedValue);
            }

            SaveDataToDataBase(cce);
        }
Пример #7
0
        private void SaveDataToDataBase(CarClassEntity cce)
        {
            string message;

            if (cce.Id == 0)
            {
                cce.CountryId = int.Parse(ddlCountry.SelectedValue);
                using (var dataAccess = new MappingDeleteAndCreate())
                {
                    message = dataAccess.CreateNewCarClass(cce);
                }
            }
            else
            {
                using (var dataAccess = new MappingSingleUpdate())
                {
                    message = dataAccess.UpdateCarClass(cce);
                }
            }

            ProcessDatabaseReply(message, UpdateCarClassSuccess, AdminMappingEnum.CarClass, lblMessage);
        }
Пример #8
0
        public string UpdateCarClass(CarClassEntity cce)
        {
            var carClassDbEntry = DataContext.CAR_CLASSes.Single(d => d.car_class_id == cce.Id);

            var classAlreadyExistsInCountry =
                CarClassEntityCheck.DoesClassExistForCountry(DataContext, cce.CarClassName,
                                                             carClassDbEntry.CAR_SEGMENT.COUNTRy1.CountryId
                                                             , cce.Id);

            if (classAlreadyExistsInCountry)
            {
                return(CarClassEntityCheck.ClassAlreadyExistsForCountry);
            }

            carClassDbEntry.car_class1 = cce.CarClassName;
            //carClassDbEntry.car_segment_id = cce.CarSegmentId;

            carClassDbEntry.IsActive = cce.Active;

            var returned = SubmitDbChanges();

            return(returned);
        }