/// <summary> /// Add New or Update the SuppliesDotComParameters based on if we pass the SuppliesDotComParameters ID in the SuppliesDotComParametersViewModel object. /// </summary> /// <param name="model"></param> /// <returns>returns the newly added or updated ID of SuppliesDotComParameters row</returns> public JsonResult SaveSuppliesDotComParameters(BillingSystemParameters model) { var id = -1; //Initialize the newId variable var userId = Helpers.GetLoggedInUserId(); var currentDate = Helpers.GetInvariantCultureDateTime(); //Check if Model is not null if (model != null) { using (var bal = new SuppliesDotComParametersBal()) { ///* // * in case table number of logged-in user's Facility and Corporate is updated, it updates the same in the session. // */ //if (model.FacilityNumber.Trim().Equals(Helpers.GetDefaultFacilityNumber()) && model.CorporateId == Helpers.GetSysAdminCorporateID()) //{ // var objSession = Session[SessionNames.SessionClass.ToString()] as SessionClass; // if (objSession != null) // objSession.TableNumber = !string.IsNullOrEmpty(model.TableNumber) // ? model.TableNumber // : "1001"; //} if (model.Id > 0) { model.ModifiedBy = userId; model.ModifiedDate = currentDate; } else { model.CreatedBy = userId; model.CreatedDate = currentDate; //model.CorporateId = model.CorporateId; model.IsActive = true; } //Call the AddSuppliesDotComParameters Method to Add / Update current SuppliesDotComParameters id = bal.SaveSuppliesDotComParameters(model); } } return(Json(id)); }
///// <summary> ///// Get the Entity ///// </summary> ///// <returns>Return the Entity List</returns> //public List<SuppliesDotComParametersCustomModel> GetSuppliesDotComParametersList(int corporateId) //{ // var list = new List<SuppliesDotComParametersCustomModel>(); // using (var rep = UnitOfWork.SuppliesDotComParametersRepository) // { // var lstSuppliesDotComParameters = corporateId > 0 // ? rep.Where(a => a.IsActive && a.CorporateId == corporateId).ToList() // : rep.Where(a => a.IsActive).ToList(); // if (lstSuppliesDotComParameters.Count > 0) // { // list.AddRange(lstSuppliesDotComParameters.Select(item => new SuppliesDotComParametersCustomModel // { // Id = item.Id, // ARGLacct = item.ARGLacct, // BadDebtGLacct = item.BadDebtGLacct, // BillHoldDays = item.BillHoldDays, // CreatedBy = item.CreatedBy, // CreatedDate = item.CreatedDate, // EffectiveDate = item.EffectiveDate, // EndDate = item.EndDate, // ERCloseBillsHours = item.ERCloseBillsHours, // ExternalValue1 = item.ExternalValue1, // ExternalValue2 = item.ExternalValue2, // ExternalValue3 = item.ExternalValue3, // ExternalValue4 = item.ExternalValue4, // FacilityName = GetFacilityNameByNumber(item.FacilityNumber), // FacilityNumber = item.FacilityNumber, // IsActive = item.IsActive, // MgdCareGLacct = item.MgdCareGLacct, // ModifiedBy = item.ModifiedBy, // ModifiedDate = item.ModifiedDate, // OupatientCloseBillsTime = item.OupatientCloseBillsTime, // SmallBalanceAmount = item.SmallBalanceAmount, // SmallBalanceGLacct = item.SmallBalanceGLacct, // SmallBalanceWriteoffDays = item.SmallBalanceWriteoffDays // })); // } // } // return list; //} ///// <summary> ///// Method to add the Entity in the database By Id. ///// </summary> ///// <param name="id"></param> ///// <returns></returns> //public SuppliesDotComParameters GetSuppliesDotComParametersById(int? id) //{ // using (var rep = UnitOfWork.SuppliesDotComParametersRepository) // { // var model = rep.Where(x => x.Id == id).FirstOrDefault(); // return model; // } //} /// <summary> /// Method to add/Update the Entity in the database. /// </summary> /// <param name="model"></param> /// <returns></returns> public int SaveSuppliesDotComParameters(BillingSystemParameters model) { using (var rep = UnitOfWork.BillingSystemParametersRepository) { if (model.Id > 0) { var oldValues = GetDetailsByBillingParameterId(model.Id); var current = rep.GetSingle(model.Id); model.CreatedBy = current.CreatedBy; model.CreatedDate = current.CreatedDate; rep.UpdateEntity(model, model.Id); //Updates the table Number in all the Billing Code Database Tables //rep.UpdateTableNumberInAllBillingCodes(Convert.ToInt32(model.CorporateId), model.FacilityNumber, // Convert.ToString(model.Id), oldValues.CPTTableNumber, oldValues.ServiceCodeTableNumber, oldValues.DrugTableNumber, oldValues.DRGTableNumber, oldValues.HCPCSTableNumber, oldValues.DiagnosisTableNumber); } else { try { rep.Create(model); } catch (DbEntityValidationException dbEx) { var raise = dbEx.EntityValidationErrors.Aggregate <DbEntityValidationResult, Exception>(dbEx, (current1, validationErrors) => validationErrors.ValidationErrors.Select( validationError => string.Format("{0}:{1}", validationErrors.Entry.Entity.ToString(), validationError.ErrorMessage)) .Aggregate(current1, (current, message) => new InvalidOperationException(message, current))); throw raise; } } return(model.Id); } }