public async Task <CustomerSalesOrder> Create(CustomerSalesOrder CustomerSalesOrder) { if (!await CustomerSalesOrderValidator.Create(CustomerSalesOrder)) { return(CustomerSalesOrder); } try { var SalesEmployee = await UOW.AppUserRepository.Get(CustomerSalesOrder.SalesEmployeeId); CustomerSalesOrder.CreatorId = CurrentContext.UserId; CustomerSalesOrder.OrganizationId = SalesEmployee.OrganizationId; CustomerSalesOrder.RequestStateId = RequestStateEnum.NEW.Id; await Calculator(CustomerSalesOrder); await UOW.CustomerSalesOrderRepository.Create(CustomerSalesOrder); CustomerSalesOrder = await UOW.CustomerSalesOrderRepository.Get(CustomerSalesOrder.Id); await Logging.CreateAuditLog(CustomerSalesOrder, new { }, nameof(CustomerSalesOrderService)); return(CustomerSalesOrder); } catch (Exception ex) { await Logging.CreateSystemLog(ex, nameof(CustomerSalesOrderService)); } return(null); }
public async Task <List <Store> > AddToCustomer(List <Store> Stores) { if (!await StoreValidator.AddToCustomer(Stores)) { return(Stores); } try { await UOW.Begin(); await UOW.StoreRepository.BulkMerge(Stores); await UOW.Commit(); await Logging.CreateAuditLog(Stores, new { }, nameof(StoreService)); return(Stores); } catch (Exception ex) { if (ex.InnerException == null) { await Logging.CreateSystemLog(ex, nameof(StoreService)); throw new MessageException(ex); } else { await Logging.CreateSystemLog(ex.InnerException, nameof(StoreService)); throw new MessageException(ex.InnerException); } } }
public async Task <ScheduleMaster> Create(ScheduleMaster ScheduleMaster) { if (!await ScheduleMasterValidator.Create(ScheduleMaster)) { return(ScheduleMaster); } try { await UOW.Begin(); await UOW.ScheduleMasterRepository.Create(ScheduleMaster); await UOW.Commit(); await Logging.CreateAuditLog(ScheduleMaster, new { }, nameof(ScheduleMasterService)); return(await UOW.ScheduleMasterRepository.Get(ScheduleMaster.Id)); } catch (Exception ex) { await UOW.Rollback(); await Logging.CreateSystemLog(ex.InnerException, nameof(ScheduleMasterService)); if (ex.InnerException == null) { throw new MessageException(ex); } else { throw new MessageException(ex.InnerException); } } }
public async Task <Customer> Create(Customer Customer) { if (!await CustomerValidator.Create(Customer)) { return(Customer); } try { var Creator = await UOW.AppUserRepository.Get(CurrentContext.UserId); Customer.CreatorId = Creator.Id; Customer.OrganizationId = Creator.OrganizationId; await UOW.CustomerRepository.Create(Customer); Customer = await UOW.CustomerRepository.Get(Customer.Id); await Logging.CreateAuditLog(Customer, new { }, nameof(CustomerService)); return(Customer); } catch (Exception ex) { await Logging.CreateSystemLog(ex, nameof(CustomerService)); } return(null); }
public async Task <WorkflowStep> Create(WorkflowStep WorkflowStep) { if (!await WorkflowStepValidator.Create(WorkflowStep)) { return(WorkflowStep); } try { await UOW.Begin(); await UOW.WorkflowStepRepository.Create(WorkflowStep); await UOW.Commit(); await Logging.CreateAuditLog(WorkflowStep, new { }, nameof(WorkflowStepService)); return(await UOW.WorkflowStepRepository.Get(WorkflowStep.Id)); } catch (Exception ex) { await UOW.Rollback(); await Logging.CreateSystemLog(ex.InnerException, nameof(WorkflowStepService)); if (ex.InnerException == null) { throw new MessageException(ex); } else { throw new MessageException(ex.InnerException); } } }
public async Task <FoodGrouping> Create(FoodGrouping FoodGrouping) { if (!await FoodGroupingValidator.Create(FoodGrouping)) { return(FoodGrouping); } try { await UOW.Begin(); await UOW.FoodGroupingRepository.Create(FoodGrouping); await UOW.Commit(); await Logging.CreateAuditLog(FoodGrouping, new { }, nameof(FoodGroupingService)); return(await UOW.FoodGroupingRepository.Get(FoodGrouping.Id)); } catch (Exception ex) { await UOW.Rollback(); await Logging.CreateSystemLog(ex.InnerException, nameof(FoodGroupingService)); if (ex.InnerException == null) { throw new MessageException(ex); } else { throw new MessageException(ex.InnerException); } } }
public async Task <Reservation> Create(Reservation Reservation) { if (!await ReservationValidator.Create(Reservation)) { return(Reservation); } try { await UOW.Begin(); await UOW.ReservationRepository.Create(Reservation); await UOW.Commit(); await Logging.CreateAuditLog(Reservation, new { }, nameof(ReservationService)); return(await UOW.ReservationRepository.Get(Reservation.Id)); } catch (Exception ex) { await UOW.Rollback(); await Logging.CreateSystemLog(ex.InnerException, nameof(ReservationService)); if (ex.InnerException == null) { throw new MessageException(ex); } else { throw new MessageException(ex.InnerException); } } }
public async Task <TicketType> Create(TicketType TicketType) { if (!await TicketTypeValidator.Create(TicketType)) { return(TicketType); } try { await UOW.Begin(); await UOW.TicketTypeRepository.Create(TicketType); await UOW.Commit(); await Logging.CreateAuditLog(TicketType, new { }, nameof(TicketTypeService)); return(await UOW.TicketTypeRepository.Get(TicketType.Id)); } catch (Exception ex) { await UOW.Rollback(); await Logging.CreateSystemLog(ex.InnerException, nameof(TicketTypeService)); if (ex.InnerException == null) { throw new MessageException(ex); } else { throw new MessageException(ex.InnerException); } } }
public async Task <OrderContent> Create(OrderContent OrderContent) { if (!await OrderContentValidator.Create(OrderContent)) { return(OrderContent); } try { await UOW.Begin(); await UOW.OrderContentRepository.Create(OrderContent); await UOW.Commit(); await Logging.CreateAuditLog(OrderContent, new { }, nameof(OrderContentService)); return(await UOW.OrderContentRepository.Get(OrderContent.Id)); } catch (Exception ex) { await UOW.Rollback(); await Logging.CreateSystemLog(ex.InnerException, nameof(OrderContentService)); if (ex.InnerException == null) { throw new MessageException(ex); } else { throw new MessageException(ex.InnerException); } } }
public async Task <TicketPriority> Create(TicketPriority TicketPriority) { if (!await TicketPriorityValidator.Create(TicketPriority)) { return(TicketPriority); } try { TicketPriorityFilter TicketPriorityFilter = new TicketPriorityFilter { Take = 1, Selects = TicketPrioritySelect.ALL, OrderBy = TicketPriorityOrder.OrderNumber, OrderType = OrderType.DESC }; await UOW.Begin(); if (TicketPriority.OrderNumber == 0) { List <TicketPriority> TicketPriorities = await UOW.TicketPriorityRepository.List(TicketPriorityFilter); TicketPriority.OrderNumber = TicketPriorities.Any() ? TicketPriorities.Max(c => c.OrderNumber) + 1 : 1; } await UOW.TicketPriorityRepository.Create(TicketPriority); await UOW.Commit(); TicketPriority = await UOW.TicketPriorityRepository.Get(TicketPriority.Id); await Logging.CreateAuditLog(TicketPriority, new { }, nameof(TicketPriorityService)); return(TicketPriority); } catch (Exception ex) { if (ex.InnerException == null) { await Logging.CreateSystemLog(ex, nameof(TicketPriorityService)); throw new MessageException(ex); } else { await Logging.CreateSystemLog(ex.InnerException, nameof(TicketPriorityService)); throw new MessageException(ex.InnerException); } } }
public async Task <CustomerPointHistory> Create(CustomerPointHistory CustomerPointHistory) { if (!await CustomerPointHistoryValidator.Create(CustomerPointHistory)) { return(CustomerPointHistory); } try { var oldDatas = await UOW.CustomerPointHistoryRepository.List(new CustomerPointHistoryFilter { Skip = 0, Take = int.MaxValue, Selects = CustomerPointHistorySelect.ALL, CustomerId = new IdFilter { Equal = CustomerPointHistory.CustomerId }, }); CustomerPointHistory.TotalPoint = oldDatas.Where(x => x.IsIncrease == true).Select(x => x.ChangePoint).DefaultIfEmpty(0).Sum(); CustomerPointHistory.CurrentPoint = oldDatas.Where(x => x.IsIncrease == true).Select(x => x.ChangePoint).DefaultIfEmpty(0).Sum() - oldDatas.Where(x => x.IsIncrease == false).Select(x => x.ChangePoint).DefaultIfEmpty(0).Sum(); if (CustomerPointHistory.IsIncrease) { CustomerPointHistory.TotalPoint += CustomerPointHistory.ChangePoint; CustomerPointHistory.CurrentPoint += CustomerPointHistory.ChangePoint; } else { CustomerPointHistory.CurrentPoint -= CustomerPointHistory.ChangePoint; if (CustomerPointHistory.ReduceTotal) { CustomerPointHistory.TotalPoint -= CustomerPointHistory.ChangePoint; } } await UOW.CustomerPointHistoryRepository.Create(CustomerPointHistory); CustomerPointHistory = await UOW.CustomerPointHistoryRepository.Get(CustomerPointHistory.Id); await Logging.CreateAuditLog(CustomerPointHistory, new { }, nameof(CustomerPointHistoryService)); return(CustomerPointHistory); } catch (Exception ex) { await Logging.CreateSystemLog(ex, nameof(CustomerPointHistoryService)); } return(null); }
public async Task <KpiGeneral> Create(KpiGeneral KpiGeneral) { if (!await KpiGeneralValidator.Create(KpiGeneral)) { return(KpiGeneral); } try { await UOW.Begin(); List <KpiGeneral> KpiGenerals = new List <KpiGeneral>(); if (KpiGeneral.EmployeeIds != null && KpiGeneral.EmployeeIds.Any()) { foreach (var EmployeeId in KpiGeneral.EmployeeIds) { var newObj = Utils.Clone(KpiGeneral); newObj.EmployeeId = EmployeeId; newObj.CreatorId = CurrentContext.UserId; newObj.RowId = Guid.NewGuid(); KpiGenerals.Add(newObj); } } await UOW.KpiGeneralRepository.BulkMerge(KpiGenerals); await UOW.Commit(); await Logging.CreateAuditLog(KpiGeneral, new { }, nameof(KpiGeneralService)); return(KpiGeneral); } catch (Exception ex) { await UOW.Rollback(); if (ex.InnerException == null) { await Logging.CreateSystemLog(ex, nameof(KpiGeneralService)); throw new MessageException(ex); } else { await Logging.CreateSystemLog(ex.InnerException, nameof(KpiGeneralService)); throw new MessageException(ex.InnerException); } } }
public async Task <KnowledgeArticle> Create(KnowledgeArticle KnowledgeArticle) { if (!await KnowledgeArticleValidator.Create(KnowledgeArticle)) { return(KnowledgeArticle); } try { KnowledgeArticle.KMSStatusId = KMSStatusEnum.NEW.Id; var Now = StaticParams.DateTimeNow; if (Now >= KnowledgeArticle.FromDate && (KnowledgeArticle.ToDate.HasValue == false || KnowledgeArticle.ToDate >= Now)) { KnowledgeArticle.KMSStatusId = KMSStatusEnum.DOING.Id; } else if (KnowledgeArticle.ToDate < Now) { KnowledgeArticle.KMSStatusId = KMSStatusEnum.EXPIRED.Id; } await UOW.Begin(); await UOW.KnowledgeArticleRepository.Create(KnowledgeArticle); await UOW.Commit(); KnowledgeArticle = await UOW.KnowledgeArticleRepository.Get(KnowledgeArticle.Id); await Logging.CreateAuditLog(KnowledgeArticle, new { }, nameof(KnowledgeArticleService)); return(KnowledgeArticle); } catch (Exception ex) { if (ex.InnerException == null) { await Logging.CreateSystemLog(ex, nameof(KnowledgeArticleService)); throw new MessageException(ex); } else { await Logging.CreateSystemLog(ex.InnerException, nameof(KnowledgeArticleService)); throw new MessageException(ex.InnerException); } } }
public async Task <Company> Create(Company Company) { if (!await CompanyValidator.Create(Company)) { return(Company); } try { await UOW.Begin(); var Creator = await UOW.AppUserRepository.Get(CurrentContext.UserId); Company.CreatorId = Creator.Id; Company.OrganizationId = Creator.OrganizationId; Company.CompanyStatusId = CompanyStatusEnum.NEW.Id; await UOW.CompanyRepository.Create(Company); await UOW.CompanyRepository.Update(Company); await UOW.Commit(); Company = await UOW.CompanyRepository.Get(Company.Id); await Logging.CreateAuditLog(Company, new { }, nameof(CompanyService)); return(Company); } catch (Exception ex) { if (ex.InnerException == null) { await Logging.CreateSystemLog(ex, nameof(CompanyService)); throw new MessageException(ex); } else { await Logging.CreateSystemLog(ex.InnerException, nameof(CompanyService)); throw new MessageException(ex.InnerException); } } }
public async Task <OrderQuote> Create(OrderQuote OrderQuote) { if (!await OrderQuoteValidator.Create(OrderQuote)) { return(OrderQuote); } try { await UOW.Begin(); var Creator = await UOW.AppUserRepository.Get(CurrentContext.UserId); OrderQuote.CreatorId = Creator.Id; OrderQuote.OrganizationId = Creator.OrganizationId; OrderQuote.OrderQuoteStatusId = OrderQuoteStatusEnum.NEW.Id; await UOW.OrderQuoteRepository.Create(OrderQuote); await UOW.OrderQuoteRepository.Update(OrderQuote); await UOW.Commit(); OrderQuote = await UOW.OrderQuoteRepository.Get(OrderQuote.Id); await Logging.CreateAuditLog(OrderQuote, new { }, nameof(OrderQuoteService)); return(OrderQuote); } catch (Exception ex) { if (ex.InnerException == null) { await Logging.CreateSystemLog(ex, nameof(OrderQuoteService)); throw new MessageException(ex); } else { await Logging.CreateSystemLog(ex.InnerException, nameof(OrderQuoteService)); throw new MessageException(ex.InnerException); } } }
public async Task <Contract> Create(Contract Contract) { if (!await ContractValidator.Create(Contract)) { return(Contract); } try { var CurrentUser = await UOW.AppUserRepository.Get(CurrentContext.UserId); Contract.CreatorId = CurrentUser.Id; Contract.OrganizationId = CurrentUser.OrganizationId; await UOW.Begin(); await UOW.ContractRepository.Create(Contract); await UOW.Commit(); Contract = await UOW.ContractRepository.Get(Contract.Id); await Logging.CreateAuditLog(Contract, new { }, nameof(ContractService)); return(Contract); } catch (Exception ex) { if (ex.InnerException == null) { await Logging.CreateSystemLog(ex, nameof(ContractService)); throw new MessageException(ex); } else { await Logging.CreateSystemLog(ex.InnerException, nameof(ContractService)); throw new MessageException(ex.InnerException); } } }
public async Task <TicketGeneratedId> GetNewTicketId() { try { TicketGeneratedId ticketUnused = await UOW.TicketGeneratedIdRepository.GetTicketGeneratedIdUnused(); if (ticketUnused != null) { return(ticketUnused); } TicketGeneratedId TicketGeneratedId = new TicketGeneratedId(); await UOW.Begin(); await UOW.TicketGeneratedIdRepository.Create(TicketGeneratedId); await UOW.Commit(); TicketGeneratedId = await UOW.TicketGeneratedIdRepository.Get(TicketGeneratedId.Id); await Logging.CreateAuditLog(TicketGeneratedId, new { }, nameof(TicketGeneratedIdService)); return(TicketGeneratedId); } catch (Exception ex) { if (ex.InnerException == null) { await Logging.CreateSystemLog(ex, nameof(TicketGeneratedIdService)); throw new MessageException(ex); } else { await Logging.CreateSystemLog(ex.InnerException, nameof(TicketGeneratedIdService)); throw new MessageException(ex.InnerException); } } }
public async Task <CallLog> Create(CallLog CallLog) { if (!await CallLogValidator.Create(CallLog)) { return(CallLog); } try { CallLog.CreatorId = CurrentContext.UserId; await UOW.Begin(); await UOW.CallLogRepository.Create(CallLog); await UOW.Commit(); CallLog = await UOW.CallLogRepository.Get(CallLog.Id); NotifyUsed(CallLog); await Logging.CreateAuditLog(CallLog, new { }, nameof(CallLogService)); return(CallLog); } catch (Exception ex) { if (ex.InnerException == null) { await Logging.CreateSystemLog(ex, nameof(CallLogService)); throw new MessageException(ex); } else { await Logging.CreateSystemLog(ex.InnerException, nameof(CallLogService)); throw new MessageException(ex.InnerException); } } }
public async Task <OpportunityActivity> Create(OpportunityActivity OpportunityActivity) { if (!await OpportunityActivityValidator.Create(OpportunityActivity)) { return(OpportunityActivity); } try { await UOW.OpportunityActivityRepository.Create(OpportunityActivity); OpportunityActivity = await UOW.OpportunityActivityRepository.Get(OpportunityActivity.Id); await Logging.CreateAuditLog(OpportunityActivity, new { }, nameof(OpportunityActivityService)); return(OpportunityActivity); } catch (Exception ex) { await Logging.CreateSystemLog(ex, nameof(OpportunityActivityService)); } return(null); }
public async Task <Profession> Create(Profession Profession) { if (!await ProfessionValidator.Create(Profession)) { return(Profession); } try { await UOW.ProfessionRepository.Create(Profession); Profession = await UOW.ProfessionRepository.Get(Profession.Id); await Logging.CreateAuditLog(Profession, new { }, nameof(ProfessionService)); return(Profession); } catch (Exception ex) { await Logging.CreateSystemLog(ex, nameof(ProfessionService)); } return(null); }
public async Task <CheckingStatus> Create(CheckingStatus CheckingStatus) { if (!await CheckingStatusValidator.Create(CheckingStatus)) { return(CheckingStatus); } try { await UOW.CheckingStatusRepository.Create(CheckingStatus); CheckingStatus = await UOW.CheckingStatusRepository.Get(CheckingStatus.Id); await Logging.CreateAuditLog(CheckingStatus, new { }, nameof(CheckingStatusService)); return(CheckingStatus); } catch (Exception ex) { await Logging.CreateSystemLog(ex, nameof(CheckingStatusService)); } return(null); }
public async Task <CustomerFeedback> Create(CustomerFeedback CustomerFeedback) { if (!await CustomerFeedbackValidator.Create(CustomerFeedback)) { return(CustomerFeedback); } try { await UOW.CustomerFeedbackRepository.Create(CustomerFeedback); CustomerFeedback = await UOW.CustomerFeedbackRepository.Get(CustomerFeedback.Id); await Logging.CreateAuditLog(CustomerFeedback, new { }, nameof(CustomerFeedbackService)); return(CustomerFeedback); } catch (Exception ex) { await Logging.CreateSystemLog(ex, nameof(CustomerFeedbackService)); } return(null); }
public async Task <CustomerSalesOrderContent> Create(CustomerSalesOrderContent CustomerSalesOrderContent) { if (!await CustomerSalesOrderContentValidator.Create(CustomerSalesOrderContent)) { return(CustomerSalesOrderContent); } try { await UOW.CustomerSalesOrderContentRepository.Create(CustomerSalesOrderContent); CustomerSalesOrderContent = await UOW.CustomerSalesOrderContentRepository.Get(CustomerSalesOrderContent.Id); await Logging.CreateAuditLog(CustomerSalesOrderContent, new { }, nameof(CustomerSalesOrderContentService)); return(CustomerSalesOrderContent); } catch (Exception ex) { await Logging.CreateSystemLog(ex, nameof(CustomerSalesOrderContentService)); } return(null); }
public async Task <CustomerPhone> Create(CustomerPhone CustomerPhone) { if (!await CustomerPhoneValidator.Create(CustomerPhone)) { return(CustomerPhone); } try { await UOW.CustomerPhoneRepository.Create(CustomerPhone); CustomerPhone = await UOW.CustomerPhoneRepository.Get(CustomerPhone.Id); await Logging.CreateAuditLog(CustomerPhone, new { }, nameof(CustomerPhoneService)); return(CustomerPhone); } catch (Exception ex) { await Logging.CreateSystemLog(ex, nameof(CustomerPhoneService)); } return(null); }
public async Task <Tracking> Create(Tracking Tracking) { if (!await TrackingValidator.Create(Tracking)) { return(Tracking); } try { await UOW.TrackingRepository.Create(Tracking); Tracking = await UOW.TrackingRepository.Get(Tracking.Id); await Logging.CreateAuditLog(Tracking, new { }, nameof(TrackingService)); return(Tracking); } catch (Exception ex) { await Logging.CreateSystemLog(ex, nameof(TrackingService)); } return(null); }
public async Task <ContactActivity> Create(ContactActivity ContactActivity) { if (!await ContactActivityValidator.Create(ContactActivity)) { return(ContactActivity); } try { await UOW.ContactActivityRepository.Create(ContactActivity); ContactActivity = await UOW.ContactActivityRepository.Get(ContactActivity.Id); await Logging.CreateAuditLog(ContactActivity, new { }, nameof(ContactActivityService)); return(ContactActivity); } catch (Exception ex) { await Logging.CreateSystemLog(ex, nameof(ContactActivityService)); } return(null); }
public async Task <PhoneType> Create(PhoneType PhoneType) { if (!await PhoneTypeValidator.Create(PhoneType)) { return(PhoneType); } try { await UOW.PhoneTypeRepository.Create(PhoneType); PhoneType = await UOW.PhoneTypeRepository.Get(PhoneType.Id); await Logging.CreateAuditLog(PhoneType, new { }, nameof(PhoneTypeService)); return(PhoneType); } catch (Exception ex) { await Logging.CreateSystemLog(ex, nameof(PhoneTypeService)); } return(null); }
public async Task <CallEmotion> Create(CallEmotion CallEmotion) { if (!await CallEmotionValidator.Create(CallEmotion)) { return(CallEmotion); } try { await UOW.CallEmotionRepository.Create(CallEmotion); CallEmotion = await UOW.CallEmotionRepository.Get(CallEmotion.Id); await Logging.CreateAuditLog(CallEmotion, new { }, nameof(CallEmotionService)); return(CallEmotion); } catch (Exception ex) { await Logging.CreateSystemLog(ex, nameof(CallEmotionService)); } return(null); }
public async Task <CustomerCCEmailHistory> Create(CustomerCCEmailHistory CustomerCCEmailHistory) { if (!await CustomerCCEmailHistoryValidator.Create(CustomerCCEmailHistory)) { return(CustomerCCEmailHistory); } try { await UOW.CustomerCCEmailHistoryRepository.Create(CustomerCCEmailHistory); CustomerCCEmailHistory = await UOW.CustomerCCEmailHistoryRepository.Get(CustomerCCEmailHistory.Id); await Logging.CreateAuditLog(CustomerCCEmailHistory, new { }, nameof(CustomerCCEmailHistoryService)); return(CustomerCCEmailHistory); } catch (Exception ex) { await Logging.CreateSystemLog(ex, nameof(CustomerCCEmailHistoryService)); } return(null); }
public async Task <CustomerLevel> Create(CustomerLevel CustomerLevel) { if (!await CustomerLevelValidator.Create(CustomerLevel)) { return(CustomerLevel); } try { await UOW.CustomerLevelRepository.Create(CustomerLevel); CustomerLevel = await UOW.CustomerLevelRepository.Get(CustomerLevel.Id); await Logging.CreateAuditLog(CustomerLevel, new { }, nameof(CustomerLevelService)); return(CustomerLevel); } catch (Exception ex) { await Logging.CreateSystemLog(ex, nameof(CustomerLevelService)); } return(null); }