public EvaluationConcrete(DatabaseContext context, IConfiguration configuration) : base(context) { // _context = context; _configuration = configuration; notificationConcrete = new NotificationConcrete(_context, _configuration); employeesConcrete = new EmployeesConcrete(_context, _configuration); emails = new EmailsNotificationConcrete(_context, _configuration); attachmentConcrete = new AttachmentConcrete(_context, _configuration); }
// private readonly IFactory _factory; public RequestConcrete(DatabaseContext context, IConfiguration configuration) : base(context) { // _context = context; _configuration = configuration; //this._factory = factory; notificationConcrete = new NotificationConcrete(_context, _configuration); emails = new EmailsNotificationConcrete(_context, _configuration); attachmentConcrete = new AttachmentConcrete(_context, _configuration); employeesConcrete = new EmployeesConcrete(_context, _configuration); requestTypeConcrete = new RequestTypeConcrete(_context, _configuration); }
public async Task <Evaluation> saveEvaluation(EvaluationViewModel evaluationVM, int UserID) { checkBissines(evaluationVM, UserID, "Insert"); Evaluation evaluation = new Evaluation() { EvaluationID = 0, EvalCharterID = evaluationVM.evaluationVM.EvalCharterID, EmployeeID = evaluationVM.evaluationVM.EmployeeID, UserID = evaluationVM.evaluationVM.UserID, Notes = evaluationVM.evaluationVM.Notes }; await _context.Evaluations.AddAsync(evaluation); evaluationVM.evaluationCharterItems = new List <EvaluationCharterItem>(); foreach (EvalCharterCommunityViewModel obj in evaluationVM.evalCharterCommunityItemsVM) { EvaluationCharterItem item = new EvaluationCharterItem { EvaluationCharterItemsID = 0, EvaluationID = evaluation.EvaluationID, EvalCharterDetailsItemsID = obj.EvalCharterDetailsItemsID, DegreeEmployee = Convert.ToInt16(obj.DegreeEmployee) }; evaluationVM.evaluationCharterItems.Add(item); } await _context.AddRangeAsync(evaluationVM.evaluationCharterItems); await _context.SaveChangesAsync(); AttachmentConcrete attachmentConcrete = new AttachmentConcrete(_context, _configuration); if (evaluationVM.attachments != null) { foreach (Attachment dtl in evaluationVM.attachments) { Attachment obj = _context.Attachments.FirstOrDefault(p => p.AttachmentID == dtl.AttachmentID); obj.ReferenceID = evaluation.EvaluationID; await attachmentConcrete.UpdateAttachment(obj); } } Employee employeeManager = _context.EmployeeInfoView.Where(p => p.ManagerID == evaluationVM.evaluationVM.EmployeeID).FirstOrDefault(); Users usersManager = _context.Users.Where(p => p.EmployeeId == employeeManager.EmployeeID).FirstOrDefault(); if (usersManager != null) { await notificationConcrete.SaveNotification(evaluation.EvaluationID, false, "NOT02", usersManager.UserId, 0, UserID); } return(evaluation); }
public async Task <PurchasesVM> updatePurchases(PurchasesVM PurchasesVM) { _context.Purchases.Update(PurchasesVM.purchases); foreach (PurchasesDetails dtl in PurchasesVM.purchasesDetails) { dtl.PurchaseID = PurchasesVM.purchases.PurchaseID; dtl.PurchasesDetailsID = 0; if (PurchasesVM.purchases.PurchaseID < dtl.ItemTypeID) { PurchasesVM.purchases.TypeID = dtl.ItemTypeID; } } List <PurchasesDetails> Oldresult = _context.PurchasesDetails.Where(p => p.PurchaseID == PurchasesVM.purchases.PurchaseID).ToList(); _context.RemoveRange(Oldresult); if (PurchasesVM.purchasesDetails != null) { await _context.AddRangeAsync(PurchasesVM.purchasesDetails); } var result = await _context.SaveChangesAsync(); AttachmentConcrete attachmentConcrete = new AttachmentConcrete(_context, _configuration); if (PurchasesVM.attachments != null) { foreach (Attachment dtl in PurchasesVM.attachments) { Attachment obj = _context.Attachments.FirstOrDefault(p => p.AttachmentID == dtl.AttachmentID); obj.ReferenceID = PurchasesVM.purchases.PurchaseID; await attachmentConcrete.UpdateAttachment(obj); } } if (result > 0) { return(PurchasesVM); } else { throw new Exception("Not Update"); } }
public async Task <PurchaseOffersVM> SavePurchaseOffers(PurchaseOffersVM purchaseOffersVM) { await _context.PurchaseOffers.AddRangeAsync(purchaseOffersVM.purchaseOffers); await _context.SaveChangesAsync(); AttachmentConcrete attachmentConcrete = new AttachmentConcrete(_context, _configuration); if (purchaseOffersVM.attachments != null) { foreach (Attachment dtl in purchaseOffersVM.attachments) { Attachment obj = _context.Attachments.FirstOrDefault(p => p.AttachmentID == dtl.AttachmentID); if (obj != null) { obj.ReferenceID = purchaseOffersVM.purchaseOffers.PurchaseOfferID; await attachmentConcrete.UpdateAttachment(obj); } } } return(purchaseOffersVM); }
public async Task <PurchasesVM> savePurchases(PurchasesVM PurchasesVM) { await _context.Purchases.AddAsync(PurchasesVM.purchases); foreach (PurchasesDetails dtl in PurchasesVM.purchasesDetails) { dtl.PurchaseID = PurchasesVM.purchases.PurchaseID; if (PurchasesVM.purchases.PurchaseID < dtl.ItemTypeID) { PurchasesVM.purchases.TypeID = dtl.ItemTypeID; } } if (PurchasesVM.purchasesDetails != null) { await _context.AddRangeAsync(PurchasesVM.purchasesDetails); } await _context.SaveChangesAsync(); AttachmentConcrete attachmentConcrete = new AttachmentConcrete(_context, _configuration); if (PurchasesVM.attachments != null) { foreach (Attachment dtl in PurchasesVM.attachments) { Attachment obj = _context.Attachments.FirstOrDefault(p => p.AttachmentID == dtl.AttachmentID); obj.ReferenceID = PurchasesVM.purchases.PurchaseID; await attachmentConcrete.UpdateAttachment(obj); } } await _context.SaveChangesAsync(); return(PurchasesVM); }