Ejemplo n.º 1
0
        private void DeleteCurrentService()
        {
            Entities.Service service =
                (Entities.Service) this.dgvServices.SelectedItem;

            Presentation.Controllers.TourServices.Delete(service);
        }
Ejemplo n.º 2
0
        internal bool Update(Entities.Service service)
        {
            bool res = false;

            try
            {
                this.query.Parameters.Clear();

                this.query.Parameters.Add(new SqlParameter("@ServiceName", service.Name));
                this.query.Parameters.Add(new SqlParameter("@PricePerPerson", service.PricePerPerson.Value));
                this.query.Parameters.Add(new SqlParameter("@PriceUnitId", service.PricePerPerson.Currency.Id));
                this.query.Parameters.Add(new SqlParameter("@TypeId", service.ServiceType.Id));
                this.query.Parameters.Add(new SqlParameter("@ServiceId", service.Id));


                int affected;
                res = this.query.ExecuteUpdateProc("ServicesUpdateById", out affected);
            }
            catch (Exception ex)
            {
                try
                {
                    DomainModel.Application.Status.Update(
                        StatusController.Abstract.StatusTypes.Error,
                        "",
                        ex.Message);
                }
                catch { }
            }

            return(res);
        }
Ejemplo n.º 3
0
 internal static void Delete(Entities.Service service)
 {
     if (Controllers.MessageBox.ConfirmDelete())
     {
         DomainModel.Services.Delete(service);
     }
 }
Ejemplo n.º 4
0
 internal static void Edit(Entities.Service service)
 {
     using (FrmServiceSettingEditor frm = new FrmServiceSettingEditor(service))
     {
         frm.ShowDialog();
     }
 }
Ejemplo n.º 5
0
        public async Task <bool> DeleteServiceAsync(int id)
        {
            var entity = new Entities.Service
            {
                Id = id
            };

            Context.Entry(entity).State = EntityState.Deleted;
            var result = await Context.SaveChangesAsync();

            return(result > 0);
        }
Ejemplo n.º 6
0
        void cbxServiceTypes_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            if (this.cbxServiceTypes.SelectedIndex >= 0)
            {
                Entities.Service service = (Entities.Service)
                                           this.cbxServiceTypes.Items[this.cbxServiceTypes.SelectedIndex];

                if (this.service.Detail != service)
                {
                    this.service.Detail = service;
                }
            }
        }
        private void GetControlData()
        {
            if (this.service == null)
            {
                this.service = new Entities.Service();
            }

            this.service.Name = this.tbxServiceName.Text;
            this.service.PricePerPerson.Value    = this.mpkBasePrice.Value.Value;
            this.service.PricePerPerson.Currency = this.mpkBasePrice.Value.Currency;
            this.service.ServiceType             = (Entities.GeneralType)
                                                   this.cbxServiceTypes.SelectedItem;
        }
Ejemplo n.º 8
0
        public void Delete(Entities.Service value)
        {
            using (var scope = _dbContextScopeFactory.Create())
            {
                var dbContext = scope.DbContexts
                                .Get <ApplicationDbContext>();

                var existed = dbContext.Set <Service>().SingleOrDefault(s => s.ID == value.ID);

                dbContext.Set <Service>().Remove(existed);

                scope.SaveChanges();
            }
        }
Ejemplo n.º 9
0
        protected void MapServiceToObject(SqlDataReader reader, object userData)
        {
            Entities.Service service = new Entities.Service();

            service.Id          = Utils.GetSafeInt32(reader, "ServiceId");
            service.ServiceType = DomainModel.ServiceTypes.GetById(
                Utils.GetSafeInt32(reader, "TypeId"));
            service.PricePerPerson.Value    = Utils.GetSafeDecimal(reader, "PricePerPerson");
            service.PricePerPerson.Currency = DomainModel.Currencies.GetById(
                Utils.GetSafeInt32(reader, "PriceUnitId"));
            service.Name = Utils.GetSafeString(reader, "ServiceName");

            service.IsDirty = false;

            Entities.ServiceCollection services =
                (Entities.ServiceCollection)userData;
            services.Add(service);
        }
Ejemplo n.º 10
0
        public void Update(Entities.Service value)
        {
            using (var scope = _dbContextScopeFactory.Create())
            {
                var dbContext = scope.DbContexts
                                .Get <ApplicationDbContext>();

                var existed = dbContext.Set <Service>().SingleOrDefault(s => s.ID == value.ID);

                existed.Content              = value.Content;
                existed.Description          = value.Description;
                existed.Title                = value.Title;
                existed.SubTitle             = value.SubTitle;
                existed.ServiceSubcategoryID = value.ServiceSubcategoryID;

                existed.Image = HandleFile(existed.Image, value.Image);

                scope.SaveChanges();
            }
        }
Ejemplo n.º 11
0
 //сохранение и изменение объекта
 public void SaveService(Entities.Service service)
 {
     //если service.Id == default значит это новая запись
     if (service.Id == default)
     {
         //устанавливаем дату создания
         service.DateCreated = DateTime.UtcNow;
         //устанавливаем дату изменения
         service.DateUpdated = service.DateCreated;
         //помечаем ключем, что это новый объект
         context.Entry(service).State = EntityState.Added;
     }            
     else
     {
         //устанавливаем дату изменения
         service.DateUpdated = DateTime.UtcNow;
         //помечаем ключом, что это измененный объект
         context.Entry(service).State = EntityState.Modified;
     }
     context.SaveChanges();
 }
Ejemplo n.º 12
0
 public static Service ToModel(this Entities.Service entity)
 {
     return(Mapper.Map <Service>(entity));
 }
 public FrmServiceSettingEditor(Entities.Service service)
     : this()
 {
     this.service = service;
     BindControls();
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Updates an entity from a model.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="entity">The entity.</param>
 public static void UpdateEntity(this Models.Service model, Entities.Service entity)
 {
     Mapper.Map(model, entity);
 }