/// <summary> /// Saves this instance. /// </summary> /// <returns>ChargeType.</returns> protected ChargeType Save() { ChargeType chargeType = new ChargeType(); chargeType.CreatedOn = DateTime.UtcNow; chargeType.UpdatedOn = DateTime.UtcNow; if (!string.IsNullOrEmpty(txtDescription.Text)) chargeType.Description = txtDescription.Text.Trim(); else chargeType.Description = ""; chargeType.IsActive = chkStatus.Checked; if (!string.IsNullOrEmpty(txtChargeName.Text)) { chargeType.Name = txtChargeName.Text.Trim(); chargeType = this.ChargeTypeService.AddChargeType(chargeType.Name, chargeType.Description, chargeType.IsActive, chargeType.CreatedOn, chargeType.UpdatedOn); } return chargeType; }
/// <summary> /// Updates the Charge /// </summary> /// <param name="charge">Charge</param> public void UpdateChargeType(ChargeType charge) { if (charge == null) throw new ArgumentNullException("charge"); charge.Name = CommonHelper.EnsureNotNull(charge.Name); charge.Name = CommonHelper.EnsureMaximumLength(charge.Name, 50); charge.Description = charge.Description; charge.CreatedOn = charge.CreatedOn; charge.UpdatedOn = DateTime.UtcNow; charge.IsActive = charge.IsActive; if (!_context.IsAttached(charge)) _context.ChargeTypes.Attach(charge); _context.SaveChanges(); }