public override VModel.Settlement Add(VModel.Settlement addObject) { VModel.Settlement insertedObjectBusiness = addObject; try { Model.Settlement newModObject = Mapper.Map <VModel.Settlement, Model.Settlement>(addObject); decimal actualNetWt = addObject.Actual_Net_Weight; if (addObject.Scale != null) { newModObject.Scale = _repository.GetQuery <Model.Scale>().SingleOrDefault(o => o.ID == addObject.Scale.ID); } if (Adding(insertedObjectBusiness, newModObject, _dbContext)) { Model.Settlement insertedObject = _repository.Add <Model.Settlement>(newModObject); _repository.SaveChanges(); insertedObjectBusiness = Mapper.Map <Model.Settlement, VModel.Settlement>(insertedObject); insertedObjectBusiness.Actual_Net_Weight = actualNetWt; Added(insertedObjectBusiness, newModObject, _dbContext); } } catch (Exception ex) { bool rethrow; rethrow = LibraryExceptionHandler.HandleException(ref ex, insertedObjectBusiness.Updated_By, insertedObjectBusiness.GetType().Name, insertedObjectBusiness.ID.ToString()); if (rethrow) { throw ex; } } return(insertedObjectBusiness); }
protected override void Modify(Expression <Func <Model.SalesOrderItem, bool> > predicate, VModel.SalesOrderItem modObject, string[] includePredicate = null) { try { Model.SalesOrderItem newModObject = Mapper.Map <VModel.SalesOrderItem, Model.SalesOrderItem>(modObject); newModObject.SalesOrder = _repository.GetQuery <Model.SalesOrder>().SingleOrDefault(o => o.ID == modObject.SalesOrder.ID); newModObject.Item = _repository.GetQuery <Model.Item>().SingleOrDefault(o => o.ID == modObject.Item.ID); //newModObject.Item_Override = _repository.GetQuery<Model.Item>().SingleOrDefault(o => o.ID == modObject.Item_Override.ID); if (Modifying(modObject, newModObject, _dbContext)) { _repository.Modify <Model.SalesOrderItem>(predicate, newModObject, includePredicate); _repository.SaveChanges(); Modified(modObject, newModObject, _dbContext); } } catch (Exception ex) { bool rethrow; rethrow = LibraryExceptionHandler.HandleException(ref ex, modObject.Updated_By, modObject.GetType().Name, modObject.ID.ToString()); if (rethrow) { throw ex; } } }
public override VModel.Container Add(VModel.Container addObject) { VModel.Container insertedObjectBusiness = addObject; try { Model.Container newModObject = Mapper.Map <VModel.Container, Model.Container>(addObject); int bookingId = 0; if (addObject.Booking != null) { bookingId = addObject.Booking.ID; } newModObject.Booking = _repository.GetQuery <Model.Booking>().SingleOrDefault(o => o.ID == bookingId); if (Adding(insertedObjectBusiness, newModObject, _dbContext)) { Model.Container insertedObject = _repository.Add <Model.Container>(newModObject); _repository.SaveChanges(); insertedObjectBusiness = Mapper.Map <Model.Container, VModel.Container>(insertedObject); Added(insertedObjectBusiness, newModObject, _dbContext); } } catch (Exception ex) { bool rethrow; rethrow = LibraryExceptionHandler.HandleException(ref ex, insertedObjectBusiness.Updated_By, insertedObjectBusiness.GetType().Name, insertedObjectBusiness.ID.ToString()); if (rethrow) { throw ex; } } return(insertedObjectBusiness); }
//protected virtual void Delete(Expression<Func<TEntityModel, bool>> predicate) //{ // _repository.Delete<TEntityModel>(predicate); // _repository.SaveChanges(); //} protected virtual void Delete(Expression <Func <TEntityModel, bool> > predicate, string[] includePredicate = null) { try { IQueryable <TEntityModel> getQuery = _repository.GetQuery <TEntityModel>(); if (includePredicate != null) { foreach (string singlePredicate in includePredicate) { getQuery = getQuery.Include(singlePredicate); } } TEntityModel dbEntity = getQuery.AsQueryable().SingleOrDefault(predicate); TEntityBusiness busEntity = Mapper.Map <TEntityModel, TEntityBusiness>(dbEntity); _repository.Delete <TEntityModel>(predicate); _repository.SaveChanges(); Deleted(busEntity, dbEntity, _dbContext); } catch (Exception ex) { bool rethrow; rethrow = LibraryExceptionHandler.HandleException(ref ex); if (rethrow) { throw ex; } } }
public override VModel.Invoice Add(VModel.Invoice addObject) { VModel.Invoice insertedObjectBusiness = addObject; try { Model.Invoice newModObject = Mapper.Map <VModel.Invoice, Model.Invoice>(addObject); if (newModObject.Booking != null) { newModObject.Booking = _repository.GetQuery <Model.Booking>().SingleOrDefault(o => o.ID == addObject.Booking.ID); } if (newModObject.Sales_Order_No != null) { newModObject.Sales_Order_No = _repository.GetQuery <Model.SalesOrder>().SingleOrDefault(o => o.ID == addObject.Sales_Order_No.ID); } if (Adding(insertedObjectBusiness, newModObject, _dbContext)) { Model.Invoice insertedObject = _repository.Add <Model.Invoice>(newModObject); _repository.SaveChanges(); insertedObjectBusiness = Mapper.Map <Model.Invoice, VModel.Invoice>(insertedObject); Added(insertedObjectBusiness, newModObject, _dbContext); } } catch (Exception ex) { bool rethrow; rethrow = LibraryExceptionHandler.HandleException(ref ex, insertedObjectBusiness.Updated_By, insertedObjectBusiness.GetType().Name, insertedObjectBusiness.ID.ToString()); if (rethrow) { throw ex; } } return(insertedObjectBusiness); }
public virtual bool SaveEmployeeRoles(int employeeID, int[] roleIDs) { bool retVal = true; try { _repository.Delete <Model.EmployeeRole>(m => m.Employee.ID == employeeID); Model.Employee emp = _repository.GetQuery <Model.Employee>().SingleOrDefault(m => m.ID == employeeID); if (roleIDs != null) { foreach (int roleID in roleIDs) { Model.Role role = _repository.GetQuery <Model.Role>().SingleOrDefault(m => m.ID == roleID); Model.EmployeeRole empRole = new Model.EmployeeRole() { Employee = emp, Role = role }; _repository.Add <Model.EmployeeRole>(empRole); } } _repository.SaveChanges(); } catch (Exception ex) { bool rethrow = LibraryExceptionHandler.HandleException(ref ex, System.Diagnostics.TraceEventType.Error); if (rethrow) { throw ex; } } return(retVal); }
protected bool Adding(TEntityBusiness businessEntity, TEntityModel modelEntity, DbContext dbContext) { bool cancel = false; try { // Check Unique constraints ValidateUniqueEntity(modelEntity, businessEntity); if (OnAdding != null) { OnAdding(businessEntity, modelEntity, dbContext, out cancel); } if (AddingHandlers.Count > 0) { foreach (BusinessRuleElement handler in AddingHandlers) { bool cancelVal = BusinessRuleEngine.InvokeMethod(handler.Type, handler.MethodName, businessEntity, modelEntity, dbContext, false); if (cancelVal) { return(false); } } } } catch (Exception ex) { bool rethrow = LibraryExceptionHandler.HandleException(ref ex, System.Diagnostics.TraceEventType.Error); if (rethrow) { throw ex; } } return(!cancel); }
protected override void Modify(Expression <Func <Model.PaymentReceipt, bool> > predicate, VModel.PaymentReceipt modObject, string[] includePredicate = null) { try { Model.PaymentReceipt newModObject = Mapper.Map <VModel.PaymentReceipt, Model.PaymentReceipt>(modObject); newModObject.Party = _repository.GetQuery <Model.Party>().SingleOrDefault(o => o.ID == modObject.Party.ID); newModObject.Account_Name = _repository.GetQuery <Model.Bank>().SingleOrDefault(o => o.ID == modObject.Account_Name.ID); if (modObject.Booking != null) { newModObject.Booking = _repository.GetQuery <Model.Booking>().SingleOrDefault(o => o.ID == modObject.Booking.ID); } if (modObject.Party_Address != null) { newModObject.Party_Address = _repository.GetQuery <Model.AddressBook>().SingleOrDefault(o => o.ID == modObject.Party_Address.ID); } if (Modifying(modObject, newModObject, _dbContext)) { _repository.Modify <Model.PaymentReceipt>(predicate, newModObject, includePredicate); _repository.SaveChanges(); Modified(modObject, newModObject, _dbContext); } } catch (Exception ex) { bool rethrow; rethrow = LibraryExceptionHandler.HandleException(ref ex, modObject.Updated_By, modObject.GetType().Name, modObject.ID.ToString()); if (rethrow) { throw ex; } } }
public override VModel.Cash Add(VModel.Cash addObject) { VModel.Cash insertedObjectBusiness = addObject; try { Model.Cash newModObject = Mapper.Map <VModel.Cash, Model.Cash>(addObject); if (addObject.Payment != null) { newModObject.Payment = _repository.GetQuery <Model.PaymentReceipt>().SingleOrDefault(o => o.ID == addObject.Payment.ID); } if (Adding(insertedObjectBusiness, newModObject, _dbContext)) { Model.Cash insertedObject = _repository.Add <Model.Cash>(newModObject); _repository.SaveChanges(); insertedObjectBusiness = Mapper.Map <Model.Cash, VModel.Cash>(insertedObject); Added(insertedObjectBusiness, newModObject, _dbContext); } } catch (Exception ex) { bool rethrow; rethrow = LibraryExceptionHandler.HandleException(ref ex, insertedObjectBusiness.Updated_By, insertedObjectBusiness.GetType().Name, insertedObjectBusiness.ID.ToString()); if (rethrow) { throw ex; } } return(insertedObjectBusiness); }
protected override void Modify(Expression <Func <Model.Cash, bool> > predicate, VModel.Cash modObject, string[] includePredicate = null) { try { Model.Cash newModObject = Mapper.Map <VModel.Cash, Model.Cash>(modObject); if (newModObject.Payment != null) { newModObject.Payment = _repository.GetQuery <Model.PaymentReceipt>().SingleOrDefault(o => o.ID == modObject.Payment.ID); } if (Modifying(modObject, newModObject, _dbContext)) { _repository.Modify <Model.Cash>(predicate, newModObject, includePredicate); _repository.SaveChanges(); Modified(modObject, newModObject, _dbContext); } } catch (Exception ex) { bool rethrow; rethrow = LibraryExceptionHandler.HandleException(ref ex, modObject.Updated_By, modObject.GetType().Name, modObject.ID.ToString()); if (rethrow) { throw ex; } } }
public virtual IEnumerable <TEntityBusiness> GetAllByPaging(IEnumerable <TEntityBusiness> newBusObjects, out int totalRows, int page, int pageSize, string sortColumn, string sortType, string[] includePredicate = null, IList <IFilterDescriptor> filters = null) { try { IEnumerable <TEntityModel> newModObjects = Mapper.Map <IEnumerable <TEntityBusiness>, IEnumerable <TEntityModel> >(newBusObjects); IEnumerable <TEntityModel> modEnumeration = _repository.GetAllByPaging <TEntityModel>(newModObjects.AsQueryable(), out totalRows, page, pageSize, sortColumn, sortType, includePredicate, filters); IEnumerable <TEntityBusiness> busEnumeration = Mapper.Map <IEnumerable <TEntityModel>, IEnumerable <TEntityBusiness> >(modEnumeration); GotMultiple(busEnumeration, modEnumeration, _dbContext); return(busEnumeration); } catch (Exception ex) { bool rethrow = LibraryExceptionHandler.HandleException(ref ex, System.Diagnostics.TraceEventType.Error); if (rethrow) { throw ex; } totalRows = 0; return(null); } }
public override VModel.SalesOrderItem Add(VModel.SalesOrderItem addObject) { VModel.SalesOrderItem insertedObjectBusiness = addObject; try { Model.SalesOrderItem newModObject = Mapper.Map <VModel.SalesOrderItem, Model.SalesOrderItem>(addObject); newModObject.SalesOrder = _repository.GetQuery <Model.SalesOrder>().SingleOrDefault(o => o.ID == addObject.SalesOrder.ID); //Added By DB to resolve multiple items adding problem newModObject.Item = _repository.GetQuery <Model.Item>().SingleOrDefault(o => o.ID == addObject.Item.ID); //newModObject.Item_Override = _repository.GetQuery<Model.Item>().SingleOrDefault(o => o.ID == addObject.Item_Override.ID); if (Adding(insertedObjectBusiness, newModObject, _dbContext)) { Model.SalesOrderItem insertedObject = _repository.Add <Model.SalesOrderItem>(newModObject); _repository.SaveChanges(); insertedObjectBusiness = Mapper.Map <Model.SalesOrderItem, VModel.SalesOrderItem>(insertedObject); Added(insertedObjectBusiness, newModObject, _dbContext); } } catch (Exception ex) { bool rethrow; rethrow = LibraryExceptionHandler.HandleException(ref ex, insertedObjectBusiness.Updated_By, insertedObjectBusiness.GetType().Name, insertedObjectBusiness.ID.ToString()); if (rethrow) { throw ex; } } return(insertedObjectBusiness); }
public override VModel.EmployeeRole Add(VModel.EmployeeRole addObject) { VModel.EmployeeRole insertedObjectBusiness = addObject; try { Model.EmployeeRole newModObject = Mapper.Map <VModel.EmployeeRole, Model.EmployeeRole>(addObject); newModObject.Role = _repository.GetQuery <Model.Role>().SingleOrDefault(o => o.ID == addObject.Role.ID); newModObject.Employee = _repository.GetQuery <Model.Employee>().SingleOrDefault(o => o.ID == addObject.Employee.ID); if (Adding(insertedObjectBusiness, newModObject, _dbContext)) { Model.EmployeeRole insertedObject = _repository.Add <Model.EmployeeRole>(newModObject); _repository.SaveChanges(); insertedObjectBusiness = Mapper.Map <Model.EmployeeRole, VModel.EmployeeRole>(insertedObject); Added(insertedObjectBusiness, newModObject, _dbContext); } } catch (Exception ex) { bool rethrow; rethrow = LibraryExceptionHandler.HandleException(ref ex, insertedObjectBusiness.Updated_By, insertedObjectBusiness.GetType().Name, insertedObjectBusiness.ID.ToString()); if (rethrow) { throw ex; } } return(insertedObjectBusiness); //return base.Add(addObject); }
public override TEntityBusiness Add(TEntityBusiness addObject) { TEntityBusiness insertedObjectBusiness = addObject; try { TEntityModel newModObject = Mapper.Map <TEntityBusiness, TEntityModel>(addObject); newModObject.Party = _repository.GetQuery <Model.Party>().SingleOrDefault(o => o.ID == addObject.Party.ID); if (Adding(insertedObjectBusiness, newModObject, _dbContext)) { TEntityModel insertedObject = _repository.Add <TEntityModel>(newModObject); _repository.SaveChanges(); insertedObjectBusiness = Mapper.Map <TEntityModel, TEntityBusiness>(insertedObject); Added(insertedObjectBusiness, newModObject, _dbContext); } } catch (Exception ex) { bool rethrow; rethrow = LibraryExceptionHandler.HandleException(ref ex, insertedObjectBusiness.Updated_By, insertedObjectBusiness.GetType().Name, insertedObjectBusiness.ID.ToString()); if (rethrow) { throw ex; } } return(insertedObjectBusiness); }
protected override void Modify(Expression <Func <Model.AssetAudit, bool> > predicate, VModel.AssetAudit modObject, string[] includePredicate = null) { try { Model.AssetAudit newModObject = Mapper.Map <VModel.AssetAudit, Model.AssetAudit>(modObject); newModObject.Asset = _repository.GetQuery <Model.Asset>().SingleOrDefault(o => o.ID == modObject.Asset.ID); newModObject.Party = _repository.GetQuery <Model.Party>().SingleOrDefault(o => o.ID == modObject.Party.ID); newModObject.Location = _repository.GetQuery <Model.AddressBook>().SingleOrDefault(o => o.ID == modObject.Location.ID); newModObject.Dispatcher_Request = _repository.GetQuery <Model.DispatcherRequest>().SingleOrDefault(o => o.ID == modObject.Dispatcher_Request.ID); if (Modifying(modObject, newModObject, _dbContext)) { _repository.Modify <Model.AssetAudit>(predicate, newModObject, includePredicate); _repository.SaveChanges(); Modified(modObject, newModObject, _dbContext); } } catch (Exception ex) { bool rethrow; rethrow = LibraryExceptionHandler.HandleException(ref ex, modObject.Updated_By, modObject.GetType().Name, modObject.ID.ToString()); if (rethrow) { throw ex; } } }
public override VModel.AssetAudit Add(VModel.AssetAudit addObject) { VModel.AssetAudit insertedObjectBusiness = addObject; try { Model.AssetAudit newModObject = Mapper.Map <VModel.AssetAudit, Model.AssetAudit>(addObject); newModObject.Asset = _repository.GetQuery <Model.Asset>().SingleOrDefault(o => o.ID == addObject.Asset.ID); newModObject.Party = _repository.GetQuery <Model.Party>().SingleOrDefault(o => o.ID == addObject.Party.ID); newModObject.Location = _repository.GetQuery <Model.AddressBook>().SingleOrDefault(o => o.ID == addObject.Location.ID); newModObject.Dispatcher_Request = _repository.GetQuery <Model.DispatcherRequest>().SingleOrDefault(o => o.ID == addObject.Dispatcher_Request.ID); if (Adding(insertedObjectBusiness, newModObject, _dbContext)) { Model.AssetAudit insertedObject = _repository.Add <Model.AssetAudit>(newModObject); _repository.SaveChanges(); insertedObjectBusiness = Mapper.Map <Model.AssetAudit, VModel.AssetAudit>(insertedObject); Added(insertedObjectBusiness, newModObject, _dbContext); } } catch (Exception ex) { bool rethrow; rethrow = LibraryExceptionHandler.HandleException(ref ex, insertedObjectBusiness.Updated_By, insertedObjectBusiness.GetType().Name, insertedObjectBusiness.ID.ToString()); if (rethrow) { throw ex; } } return(insertedObjectBusiness); }
//public override VModel.SettlementDetails Add(VModel.SettlementDetails addObject) { // VModel.SettlementDetails insertedObjectBusiness = addObject; // try { // Model.SettlementDetails newModObject = Mapper.Map<VModel.SettlementDetails, Model.SettlementDetails>(addObject); // decimal actualNetWt = addObject.Actual_Net_Weight; // if (newModObject.Scale_Details_ID != null) // newModObject.Scale_Details_ID = _repository.GetQuery<Model.ScaleDetails>().SingleOrDefault(o => o.ID == addObject.Scale_Details_ID.ID); // if (newModObject.Settlement_ID != null) // newModObject.Settlement_ID = _repository.GetQuery<Model.Settlement>().SingleOrDefault(o => o.ID == addObject.Settlement_ID.ID); // if (newModObject.Scale_Details_ID != null && newModObject.Scale_Details_ID.Apply_To_Item != null) // newModObject.Scale_Details_ID.Apply_To_Item = _repository.GetQuery<Model.Item>().SingleOrDefault(o => o.ID == addObject.Scale_Details_ID.Apply_To_Item.ID); // if (newModObject.Scale_Details_ID != null && newModObject.Scale_Details_ID.Scale != null) // newModObject.Scale_Details_ID.Scale = _repository.GetQuery<Model.Scale>().SingleOrDefault(o => o.ID == addObject.Scale_Details_ID.Scale.ID); // if (addObject.Scale_Details_ID.Scale.Purchase_Order.Price_List != null) // newModObject.Price_List_ID = _repository.GetQuery<Model.PriceList>().SingleOrDefault(o => o.ID == addObject.Scale_Details_ID.Scale.Purchase_Order.Price_List.ID); // //newModObject.Price_List_ID = _repository.GetQuery<Model.PriceList>().SingleOrDefault(o => o.ID == addObject.Settlement_ID.Scale.Purchase_Order.Price_List.ID); // if (Adding(insertedObjectBusiness, newModObject, _dbContext)) { // Model.SettlementDetails insertedObject = _repository.Add<Model.SettlementDetails>(newModObject); // _repository.SaveChanges(); // insertedObjectBusiness = Mapper.Map<Model.SettlementDetails, VModel.SettlementDetails>(insertedObject); // insertedObjectBusiness.Actual_Net_Weight = actualNetWt; // insertedObjectBusiness.Scale_Details_ID.Apply_To_Item = addObject.Scale_Details_ID.Apply_To_Item; // insertedObjectBusiness.Scale_Details_ID.Scale = addObject.Scale_Details_ID.Scale; // Added(insertedObjectBusiness, newModObject, _dbContext); // } // } // catch (Exception ex) { // bool rethrow; // rethrow = LibraryExceptionHandler.HandleException(ref ex, insertedObjectBusiness.Updated_By, insertedObjectBusiness.GetType().Name, insertedObjectBusiness.ID.ToString()); // if (rethrow) // throw ex; // } // return insertedObjectBusiness; //} public override VModel.SettlementDetails Add(VModel.SettlementDetails addObject) { VModel.SettlementDetails insertedObjectBusiness = addObject; try { Model.SettlementDetails newModObject = Mapper.Map <VModel.SettlementDetails, Model.SettlementDetails>(addObject); decimal actualNetWt = addObject.Actual_Net_Weight; if (addObject.Scale_Details_ID != null) { newModObject.Scale_Details_ID = _repository.GetQuery <Model.ScaleDetails>().SingleOrDefault(o => o.ID == addObject.Scale_Details_ID.ID); } if (addObject.Settlement_ID != null) { newModObject.Settlement_ID = _repository.GetQuery <Model.Settlement>().SingleOrDefault(o => o.ID == addObject.Settlement_ID.ID); } if (addObject.Scale_Details_ID != null && addObject.Scale_Details_ID.Apply_To_Item != null) { newModObject.Scale_Details_ID.Apply_To_Item = _repository.GetQuery <Model.Item>().SingleOrDefault(o => o.ID == addObject.Scale_Details_ID.Apply_To_Item.ID); } if (addObject.Scale_Details_ID != null && addObject.Scale_Details_ID.Scale != null) { newModObject.Scale_Details_ID.Scale = _repository.GetQuery <Model.Scale>().SingleOrDefault(o => o.ID == addObject.Scale_Details_ID.Scale.ID); } if (addObject.Scale_Details_ID != null && addObject.Scale_Details_ID.Scale != null && addObject.Scale_Details_ID.Scale.Purchase_Order != null && addObject.Scale_Details_ID.Scale.Purchase_Order.Price_List != null) { newModObject.Price_List_ID = _repository.GetQuery <Model.PriceList>().SingleOrDefault(o => o.ID == addObject.Scale_Details_ID.Scale.Purchase_Order.Price_List.ID); } //newModObject.Price_List_ID = _repository.GetQuery<Model.PriceList>().SingleOrDefault(o => o.ID == addObject.Settlement_ID.Scale.Purchase_Order.Price_List.ID); if (Adding(insertedObjectBusiness, newModObject, _dbContext)) { Model.SettlementDetails insertedObject = _repository.Add <Model.SettlementDetails>(newModObject); _repository.SaveChanges(); insertedObjectBusiness = Mapper.Map <Model.SettlementDetails, VModel.SettlementDetails>(insertedObject); insertedObjectBusiness.Actual_Net_Weight = actualNetWt; insertedObjectBusiness.Scale_Details_ID.Apply_To_Item = addObject.Scale_Details_ID.Apply_To_Item; insertedObjectBusiness.Scale_Details_ID.Scale = addObject.Scale_Details_ID.Scale; Added(insertedObjectBusiness, newModObject, _dbContext); } } catch (Exception ex) { bool rethrow; rethrow = LibraryExceptionHandler.HandleException(ref ex, insertedObjectBusiness.Updated_By, insertedObjectBusiness.GetType().Name, insertedObjectBusiness.ID.ToString()); if (rethrow) { throw ex; } } return(insertedObjectBusiness); }
public override VModel.PaymentReceiptDetails Add(VModel.PaymentReceiptDetails addObject) { VModel.PaymentReceiptDetails insertedObjectBusiness = addObject; try { int paymentRecId, settlementId, invoiceId, expReqId; paymentRecId = settlementId = invoiceId = expReqId = 0; Model.PaymentReceiptDetails newModObject = Mapper.Map <VModel.PaymentReceiptDetails, Model.PaymentReceiptDetails>(addObject); if (addObject.PaymentReceipt != null) { paymentRecId = addObject.PaymentReceipt.ID; } if (addObject.Settlement != null) { settlementId = addObject.Settlement.ID; } if (addObject.Invoice != null) { invoiceId = addObject.Invoice.ID; } if (addObject.ExpenseRequest != null) { expReqId = addObject.ExpenseRequest.ID; } newModObject.PaymentReceipt = _repository.GetQuery <Model.PaymentReceipt>().SingleOrDefault(o => o.ID == paymentRecId); newModObject.Settlement = _repository.GetQuery <Model.Settlement>().SingleOrDefault(o => o.ID == settlementId); newModObject.Invoice = _repository.GetQuery <Model.Invoice>().SingleOrDefault(o => o.ID == invoiceId); newModObject.ExpenseRequest = _repository.GetQuery <Model.ExpensesRequest>().SingleOrDefault(o => o.ID == expReqId); if (Adding(insertedObjectBusiness, newModObject, _dbContext)) { Model.PaymentReceiptDetails insertedObject = _repository.Add <Model.PaymentReceiptDetails>(newModObject); _repository.SaveChanges(); insertedObjectBusiness = Mapper.Map <Model.PaymentReceiptDetails, VModel.PaymentReceiptDetails>(insertedObject); Added(insertedObjectBusiness, newModObject, _dbContext); } } catch (Exception ex) { bool rethrow; rethrow = LibraryExceptionHandler.HandleException(ref ex, insertedObjectBusiness.Updated_By, insertedObjectBusiness.GetType().Name, insertedObjectBusiness.ID.ToString()); if (rethrow) { throw ex; } } return(insertedObjectBusiness); }
public override VModel.Booking Add(VModel.Booking addObject) { VModel.Booking insertedObjectBusiness = addObject; try { int booking_Closed_ById, shipping_CompanyId, forwarder_Party_ID, sales_Order_NoId; booking_Closed_ById = shipping_CompanyId = forwarder_Party_ID = sales_Order_NoId = 0; Model.Booking newModObject = Mapper.Map <VModel.Booking, Model.Booking>(addObject); if (addObject.Booking_Closed_By != null) { booking_Closed_ById = addObject.Booking_Closed_By.ID; } if (addObject.Shipping_Company != null) { shipping_CompanyId = addObject.Shipping_Company.ID; } if (addObject.Forwarder_Party_ID != null) { forwarder_Party_ID = addObject.Forwarder_Party_ID.ID; } if (addObject.Sales_Order_No != null) { sales_Order_NoId = addObject.Sales_Order_No.ID; } newModObject.Booking_Closed_By = _repository.GetQuery <Model.Contact>().SingleOrDefault(o => o.ID == booking_Closed_ById); newModObject.Shipping_Company = _repository.GetQuery <Model.Party>().SingleOrDefault(o => o.ID == shipping_CompanyId); newModObject.Forwarder_Party_ID = _repository.GetQuery <Model.Party>().SingleOrDefault(o => o.ID == forwarder_Party_ID); newModObject.Sales_Order_No = _repository.GetQuery <Model.SalesOrder>().SingleOrDefault(o => o.ID == sales_Order_NoId); if (Adding(insertedObjectBusiness, newModObject, _dbContext)) { Model.Booking insertedObject = _repository.Add <Model.Booking>(newModObject); _repository.SaveChanges(); insertedObjectBusiness = Mapper.Map <Model.Booking, VModel.Booking>(insertedObject); Added(insertedObjectBusiness, newModObject, _dbContext); } } catch (Exception ex) { bool rethrow; rethrow = LibraryExceptionHandler.HandleException(ref ex, insertedObjectBusiness.Updated_By, insertedObjectBusiness.GetType().Name, insertedObjectBusiness.ID.ToString()); if (rethrow) { throw ex; } } return(insertedObjectBusiness); }
public void Map() { try { Mapper.CreateMap <TEntityModel, TEntityBusiness>(); } catch (Exception ex) { bool rethrow = LibraryExceptionHandler.HandleException(ref ex, System.Diagnostics.TraceEventType.Error); if (rethrow) { throw ex; } } }
public VModel.LOV GetByValueAndParent(string lovValue, string parentLovValue) { try { return(this.GetSingleByExpression(s => s.LOV_Value == lovValue && s.Parent.LOV_Value == parentLovValue && s.Active_Ind == true, new string[] { "Parent" })); } catch (Exception ex) { bool rethrow = LibraryExceptionHandler.HandleException(ref ex, System.Diagnostics.TraceEventType.Error); if (rethrow) { throw ex; } return(null); } }
public IEnumerable <TEntityModel> Map(IEnumerable <TEntityBusiness> dbEntities) { try { IEnumerable <TEntityModel> modEntities = Mapper.Map <IEnumerable <TEntityBusiness>, IEnumerable <TEntityModel> >(dbEntities); return(modEntities); } catch (Exception ex) { bool rethrow = LibraryExceptionHandler.HandleException(ref ex, System.Diagnostics.TraceEventType.Error); if (rethrow) { throw ex; } return(null); } }
public void UpdateBalance(Expression <Func <Model.Bank, bool> > predicate, VModel.Bank modObject, string[] includePredicate = null) { try { Model.Bank newModObject = Mapper.Map <VModel.Bank, Model.Bank>(modObject); _repository.Modify <Model.Bank>(predicate, newModObject, includePredicate); _repository.SaveChanges(); } catch (Exception ex) { bool rethrow; rethrow = LibraryExceptionHandler.HandleException(ref ex, modObject.Updated_By, modObject.GetType().Name, modObject.ID.ToString()); if (rethrow) { throw ex; } } }
protected virtual void Initialize(DbContext dbContext) { try { _dbContext = dbContext; _repository = new GenericRepository(_dbContext); Mapper.CreateMap <TEntityModel, TEntityBusiness>(); Mapper.CreateMap <TEntityBusiness, TEntityModel>(); } catch (Exception ex) { bool rethrow = LibraryExceptionHandler.HandleException(ref ex, System.Diagnostics.TraceEventType.Error); if (rethrow) { throw ex; } } }
protected virtual TEntityBusiness GetSingleByExpression(Expression <Func <TEntityModel, bool> > predicate, string[] includePredicate = null) { try { TEntityBusiness entity = this.GetSingleByCriteria(predicate, includePredicate); return(entity); } catch (Exception ex) { bool rethrow; rethrow = LibraryExceptionHandler.HandleException(ref ex); if (rethrow) { throw ex; } return(null); } }
public virtual bool SetRoleFeatures(int roleID, IEnumerable <VModel.RoleFeature> roleFeatures) { bool retVal = true; try { Model.Role role = _repository.GetQuery <Model.Role>().SingleOrDefault(m => m.ID == roleID); foreach (VModel.RoleFeature roleFeature in roleFeatures) { bool isNew = false; Model.Feature feature = _repository.GetQuery <Model.Feature>().SingleOrDefault(m => m.ID == roleFeature.Feature.ID); Model.RoleFeature rFeature = null; rFeature = _repository.GetQuery <Model.RoleFeature>().SingleOrDefault(m => m.Role.ID == roleID && m.Feature.ID == feature.ID); if (rFeature == null) { rFeature = new Model.RoleFeature(); rFeature.Role = role; rFeature.Feature = feature; isNew = true; } rFeature.ViewAccessInd = roleFeature.ViewAccessInd; rFeature.EditAccessInd = roleFeature.EditAccessInd; rFeature.DeleteAccessInd = roleFeature.DeleteAccessInd; rFeature.NewAccessInd = roleFeature.NewAccessInd; if (isNew) { _repository.Add <Model.RoleFeature>(rFeature); } else { _repository.Modify <Model.RoleFeature>(m => m.Role.ID == roleID && m.Feature.ID == feature.ID, rFeature); } } _repository.SaveChanges(); } catch (Exception ex) { bool rethrow = LibraryExceptionHandler.HandleException(ref ex, System.Diagnostics.TraceEventType.Error); if (rethrow) { throw ex; } } return(retVal); }
protected override void Modify(Expression <Func <TEntityModel, bool> > predicate, TEntityBusiness modObject, string[] includePredicate = null) { try { TEntityModel newModObject = Mapper.Map <TEntityBusiness, TEntityModel>(modObject); if (newModObject.Paid_Party_To != null) { newModObject.Paid_Party_To = _repository.GetQuery <Model.Party>().SingleOrDefault(o => o.ID == newModObject.Paid_Party_To.ID); } if (newModObject.Payment != null) { newModObject.Payment = _repository.GetQuery <Model.PaymentReceipt>().SingleOrDefault(o => o.ID == newModObject.Payment.ID); } if (newModObject.Invoice != null) { newModObject.Invoice = _repository.GetQuery <Model.Invoice>().SingleOrDefault(o => o.ID == newModObject.Invoice.ID); } if (newModObject.Reference_Table == "Scale") { newModObject.Scale_Ref = _repository.GetQuery <Model.Scale>().SingleOrDefault(o => o.ID == newModObject.Reference_ID); } if (newModObject.Reference_Table == "DispatcherRequest") { newModObject.Dispatcher_Request_Ref = _repository.GetQuery <Model.DispatcherRequest>().SingleOrDefault(o => o.ID == newModObject.Reference_ID); } if (Modifying(modObject, newModObject, _dbContext)) { _repository.Modify <TEntityModel>(predicate, newModObject, includePredicate); _repository.SaveChanges(); Modified(modObject, newModObject, _dbContext); } } catch (Exception ex) { bool rethrow; rethrow = LibraryExceptionHandler.HandleException(ref ex, modObject.Updated_By, modObject.GetType().Name, modObject.ID.ToString()); if (rethrow) { throw ex; } } }
public override IEnumerable <VModel.Bank> GetAll(string[] includePredicate = null) { try { IEnumerable <Model.Bank> modEnumeration = _repository.GetAll <Model.Bank>(includePredicate); IEnumerable <VModel.Bank> busEnumeration = Mapper.Map <IEnumerable <Model.Bank>, IEnumerable <VModel.Bank> >(modEnumeration); return(busEnumeration); } catch (Exception ex) { bool rethrow = LibraryExceptionHandler.HandleException(ref ex, System.Diagnostics.TraceEventType.Error); if (rethrow) { throw ex; } return(null); } }
public virtual TEntityBusiness Modify(TEntityBusiness modObject, string[] includePredicate = null) { try { string idFieldName = "ID"; PropertyInfo property = typeof(TEntityBusiness).GetProperty(idFieldName); this.Modify(GetModelIDExpression(idFieldName, property.GetValue(modObject, null), typeof(int)), modObject, includePredicate); } catch (Exception ex) { bool rethrow; rethrow = LibraryExceptionHandler.HandleException(ref ex, modObject.Updated_By, modObject.GetType().Name, modObject.ID.ToString()); if (rethrow) { throw ex; } } return(modObject); }
public virtual IEnumerable <TEntityBusiness> GetAll(string[] includePredicate = null) { try { IEnumerable <TEntityModel> modEnumeration = _repository.GetAll <TEntityModel>(includePredicate); IEnumerable <TEntityBusiness> busEnumeration = Mapper.Map <IEnumerable <TEntityModel>, IEnumerable <TEntityBusiness> >(modEnumeration); return(busEnumeration); } catch (Exception ex) { bool rethrow = LibraryExceptionHandler.HandleException(ref ex, System.Diagnostics.TraceEventType.Error); if (rethrow) { throw ex; } return(null); } }