private void DeleteCurrentService() { Entities.Service service = (Entities.Service) this.dgvServices.SelectedItem; Presentation.Controllers.TourServices.Delete(service); }
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); }
internal static void Delete(Entities.Service service) { if (Controllers.MessageBox.ConfirmDelete()) { DomainModel.Services.Delete(service); } }
internal static void Edit(Entities.Service service) { using (FrmServiceSettingEditor frm = new FrmServiceSettingEditor(service)) { frm.ShowDialog(); } }
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); }
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; }
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(); } }
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); }
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(); } }
//сохранение и изменение объекта 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(); }
public static Service ToModel(this Entities.Service entity) { return(Mapper.Map <Service>(entity)); }
public FrmServiceSettingEditor(Entities.Service service) : this() { this.service = service; BindControls(); }
/// <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); }