/// <summary> /// Unlock order /// </summary> /// <param name="orderId">Order to unlock</param> /// <param name="userId">Current userId</param> /// <remark>This method unlock order for other user on click of save or cancel order</remark> public void UnlockOrder(int?orderId, int userId) { var _context = new DeluxeOrderManagementEntities(); if (orderId != null) { var order = _context.OrderGrids.Where(x => x.Id == orderId && x.LockedBy == userId).FirstOrDefault(); if (order != null) { order.IsLocked = false; order.LockedBy = null; order.LockedOn = null; } } else { var order = _context.OrderGrids.Where(x => x.LockedBy == userId).ToList(); foreach (var o in order) { o.IsLocked = false; o.LockedBy = null; o.LockedOn = null; } } _context.SaveChanges(); }
/// <summary> /// Log corresponding task of job into Jobs_Item table /// </summary> /// <param name="jobItem"></param> public void JobItemLog(Jobs_Items jobItem) { var _jobContext = new DeluxeOrderManagementEntities(); _jobContext.Jobs_Items.Add(jobItem); _jobContext.SaveChanges(); }
/// <summary> /// Not in use /// </summary> /// <param name="error"></param> public void LogError(ErrorLog error) { var _context = new DeluxeOrderManagementEntities(); _context.ErrorLogs.Add(error); _context.SaveChanges(); }
/// <summary> /// Log current job into JOB table /// </summary> /// <param name="job"></param> /// <returns>jonID</returns> public int JobLog(JOB job) { var _jobContext = new DeluxeOrderManagementEntities(); _jobContext.JOBS.Add(job); _jobContext.SaveChanges(); return(job.Id); }
/// <summary> /// Add Title in VID /// </summary> /// <param name="vid">This consists of all the required information need to form VID object which is further inserted into the database</param> /// <returns>Save Result</returns> public SaveResult Save(VID vid) { var _context = new DeluxeOrderManagementEntities(); _context.VIDs.Add(vid); _context.SaveChanges(); return(new SaveResult()); }
public void Save(UserModel user) { using (var _context = new DeluxeOrderManagementEntities()) { _context.UserModels.Add(user); _context.Entry(user).State = System.Data.Entity.EntityState.Added; _context.SaveChanges(); } }
/// <summary> /// Update current Job /// </summary> /// <param name="job"></param> public void UpdateJobLog(JOB job) { var _jobContext = new DeluxeOrderManagementEntities(); var jobUpdate = _jobContext.JOBS.Where(x => x.Id == job.Id).FirstOrDefault(); jobUpdate.Status = job.Status; jobUpdate.Description = job.Description; jobUpdate.FileName = job.FileName; _jobContext.SaveChanges(); }
/// <summary> /// Lock order /// </summary> /// <param name="orderId">Order to lock</param> /// <param name="userId">Current userId</param> /// <remark>This method lock order for other user</remark> public void LockOrder(int orderId, int userId) { var _context = new DeluxeOrderManagementEntities(); var order = _context.OrderGrids.Where(x => x.Id == orderId).FirstOrDefault(); order.IsLocked = true; order.LockedBy = userId; order.LockedOn = DateTime.UtcNow; _context.SaveChanges(); }
public bool ResetPassword(PasswordReset passwordReset) { DateTime utctime = DateTime.UtcNow; UserModel userEty = null; bool bresult = false; using (var _acoubntContext = new DeluxeOrderManagementEntities()) { var prety = _acoubntContext.PasswordResetModels .Include("User") .FirstOrDefault(x => x.Email == passwordReset.Email && x.Token == passwordReset.Token && x.ExpireDateTime >= utctime && (x.User != null && x.User.Active == true)); //var user = (from pr in _acoubntContext.PasswordResetEntities // join u in _acoubntContext.UserEntities on pr.UserId equals u.UserId // where pr.Email == passwordReset.Email && pr.Token == passwordReset.Token && pr.ExpireDateTime >= utctime && u.Active // select u).FirstOrDefault(); if (prety != null) { userEty = prety.User; } if (userEty != null) { UserPasswordModel upEty = new UserPasswordModel() { UserId = userEty.UserId, Password = passwordReset.Password, PasswordDate = utctime, CreatedDate = utctime }; _acoubntContext.UserPasswordModels.Add(upEty); _acoubntContext.Entry(upEty).State = System.Data.Entity.EntityState.Added; userEty.LoginAttempts = 0; _acoubntContext.Entry(userEty).State = System.Data.Entity.EntityState.Modified; //var pwdreset = (from pr in _acoubntContext.PasswordResetEntities // where pr.UserId == user.UserId // select pr).FirstOrDefault(); var prEty = _acoubntContext.PasswordResetModels.FirstOrDefault(x => x.UserId == userEty.UserId); _acoubntContext.PasswordResetModels.Remove(prEty); _acoubntContext.Entry(prEty).State = System.Data.Entity.EntityState.Deleted; bresult = true; _acoubntContext.SaveChanges(); } } return(bresult); }
public bool UpdateNotification(List <Notification> notifications) { var _context = new DeluxeOrderManagementEntities(); foreach (var notification in notifications) { var entity = _context.NotificationEntities.Where(x => x.ID == notification.ID).FirstOrDefault(); if (entity != null) { entity.Enabled = notification.Enabled; entity.ToEmailAddress = notification.ToEmailAddress; _context.SaveChanges(); } } return(true); }
public void ChangePassword(UserPasswordModel upEntity) { using (var _context = new DeluxeOrderManagementEntities()) { var ety = _context.UserModels.FirstOrDefault(e => e.UserId == upEntity.UserId); if (ety != null) { _context.UserPasswordModels.Add(upEntity); _context.Entry(upEntity).State = System.Data.Entity.EntityState.Added; ety.LoginAttempts = 0; _context.Entry(ety).State = System.Data.Entity.EntityState.Modified; _context.SaveChanges(); } } }
public void Update(UserModel user) { using (var _context = new DeluxeOrderManagementEntities()) { var ety = _context.UserModels.FirstOrDefault(x => x.UserId == user.UserId); if (ety != null) { ety.UserName = user.Email; ety.FirstName = user.FirstName; ety.LastName = user.LastName; ety.Email = user.Email; ety.PhoneNo = user.PhoneNo; ety.Title = user.Title; ety.Active = user.Active; ety.ModifiedDate = user.ModifiedDate; var userroles = ety.UserRoles.Where(x => x.UserId == user.UserId); if (userroles != null && userroles.Any()) { foreach (var userrole in userroles.ToList()) { var ur = ety.UserRoles.FirstOrDefault(x => x.UserId == userrole.UserId && x.RoleId == userrole.RoleId); ety.UserRoles.Remove(ur); _context.Entry(ur).State = System.Data.Entity.EntityState.Deleted; } } foreach (var selectedrole in user.UserRoles) { var insertedRole = new Repository.UserRoleModel() { UserId = user.UserId, RoleId = selectedrole.RoleId }; ety.UserRoles.Add(insertedRole); _context.Entry(insertedRole).State = System.Data.Entity.EntityState.Added; } _context.Entry(ety).State = System.Data.Entity.EntityState.Modified; _context.SaveChanges(); } } }
public void Delete(int id) { using (var _context = new DeluxeOrderManagementEntities()) { var ety = _context.UserModels.FirstOrDefault(x => x.UserId == id); if (ety != null) { //var upeties = _context.UserPasswordModels.Where(x => x.UserId == id); //foreach (var up in upeties) //{ // ety.UserPasswords.Remove(up); // _context.Entry(up).State = System.Data.Entity.EntityState.Deleted; //} //_context.UserModels.Remove(ety); ety.Active = false; _context.Entry(ety).State = System.Data.Entity.EntityState.Modified; _context.SaveChanges(); } } }
/// <summary> /// Create Order in the system /// </summary> /// <param name="order">Details of new order</param> /// <param name="assets">List of assets for new order</param> /// <returns>Order creation status</returns> public OrderSaveStatus CreateOrder(Order order, List <string> assets) { OrderSaveStatus orderStatus = new OrderSaveStatus(); var _context = new DeluxeOrderManagementEntities(); int languageId = Convert.ToInt32(order.Language); int territoryId = Convert.ToInt32(order.Territory); var announcement = (from ann in _context.AnnouncementGrids where ann.VideoVersion == order.Title && ann.LanguageId == languageId && ann.TerritoryId == territoryId select ann).FirstOrDefault(); if (announcement != null) { var orders = (from og in _context.OrderGrids where og.AnnouncementId == announcement.Id && assets.Contains(og.LanguageType) select og).ToList(); var vids = (from v in _context.VIDs where (v.VendorId == order.VendorId || string.IsNullOrEmpty(v.VendorId)) && v.VideoVersion == announcement.VideoVersion select v ).FirstOrDefault(); VID vid = null; //if (orders.Count == 0 || orders == null) //{ if (vids == null) { vid = new VID(); vid.VIDStatus = "PRIMARY"; vid.VendorId = order.VendorId; vid.VideoVersion = announcement.VideoVersion; vid.TitleName = announcement.Title; vid.TitleCategory = order.OrderCategory; vid.EditName = announcement.LocalEdit; vid.CreatedOn = DateTime.UtcNow; vid.ModifiedOn = DateTime.UtcNow; vid.CreatedBy = "Deluxe"; vid.ModifiedBy = "Deluxe"; _context.VIDs.Add(vid); //_context.SaveChanges(); } else { vids.VendorId = order.VendorId; } foreach (var asset in assets) { OrderGrid orderGrid = new OrderGrid() { AnnouncementId = announcement.Id, OrderStatus = order.OrderStatus, MPO = order.MPO, HALID = order.HALID, Category = order.OrderCategory, RequestNumber = order.RequestNumber, DeliveryDueDate = ParseDate(order.DueDate), GreenlightSenttoPackaging = ParseDate(order.GreenlightSent), GreenlightValidatedbyDMDM = ParseDate(order.GreenlightReceived), ActualDeliveryDate = ParseDate(order.DeliveryDate), ESTUPC = order.ESTUPC, IVODUPC = order.VODUPC, LanguageType = asset, FileType = order.OrderType, CustomerId = 1, VendorId = order.VendorId//(vid != null) ? vid.VendorId : vids.FirstOrDefault().VendorId }; _context.OrderGrids.Add(orderGrid); _context.SaveChanges(); _context.usp_UpdateOG_Status(orderGrid.Id.ToString()); } orderStatus.ErrorMessage = Constant.orderSaved; orderStatus.IsSaved = true; orderStatus.IsAnnouncementExist = true; //} //else //{ // orderStatus.ErrorMessage = Constant.orderExist; // orderStatus.IsSaved = false; // orderStatus.IsAnnouncementExist = true; //} } else if (announcement == null && !string.IsNullOrEmpty(order.LocalEdit)) { string title = _context.VIDs.Where(x => x.VideoVersion == order.Title).Select(x => x.TitleName).FirstOrDefault(); AnnouncementGrid newAnnouncement = new AnnouncementGrid() { VideoVersion = order.Title, Title = title, LanguageId = languageId, TerritoryId = territoryId, LocalEdit = order.LocalEdit, CustomerId = 1, JObId = 0 }; _context.AnnouncementGrids.Add(newAnnouncement); _context.SaveChanges(); var orders = (from og in _context.OrderGrids where og.AnnouncementId == newAnnouncement.Id && assets.Contains(og.LanguageType) select og).ToList(); var vids = (from v in _context.VIDs where v.VendorId == order.VendorId && v.VideoVersion == newAnnouncement.VideoVersion select v ).FirstOrDefault(); VID vid = null; //if (orders.Count == 0 || orders == null) //{ if (vids == null) { vid = new VID(); vid.VIDStatus = "PRIMARY"; vid.VendorId = order.VendorId; vid.VideoVersion = newAnnouncement.VideoVersion; vid.TitleName = newAnnouncement.Title; vid.TitleCategory = order.OrderCategory; vid.EditName = newAnnouncement.LocalEdit; vid.CreatedOn = DateTime.UtcNow; vid.ModifiedOn = DateTime.UtcNow; vid.CreatedBy = "Deluxe"; vid.ModifiedBy = "Deluxe"; _context.VIDs.Add(vid); _context.SaveChanges(); } else { vids.VendorId = order.VendorId; } foreach (var asset in assets) { OrderGrid orderGrid = new OrderGrid() { AnnouncementId = newAnnouncement.Id, OrderStatus = order.OrderStatus, MPO = order.MPO, HALID = order.HALID, Category = order.OrderCategory, RequestNumber = order.RequestNumber, DeliveryDueDate = ParseDate(order.DueDate), GreenlightSenttoPackaging = ParseDate(order.GreenlightSent), GreenlightValidatedbyDMDM = ParseDate(order.GreenlightReceived), ActualDeliveryDate = ParseDate(order.DeliveryDate), ESTUPC = order.ESTUPC, IVODUPC = order.VODUPC, LanguageType = asset, CustomerId = 1, VendorId = order.VendorId//(vid != null) ? vid.VendorId : vids.FirstOrDefault().VendorId }; _context.OrderGrids.Add(orderGrid); _context.SaveChanges(); _context.usp_UpdateOG_Status(orderGrid.Id.ToString()); } orderStatus.ErrorMessage = Constant.announcementNotExist; orderStatus.IsSaved = true; orderStatus.IsAnnouncementExist = false; //} //else //{ // orderStatus.ErrorMessage = Constant.orderExist; // orderStatus.IsSaved = false; // orderStatus.IsAnnouncementExist = false; //} } else { orderStatus.ErrorMessage = Constant.announcementNotExist; orderStatus.IsSaved = false; orderStatus.IsAnnouncementExist = false; } return(orderStatus); }
/// <summary> /// Edit and save selected order /// </summary> /// <param name="order">order contains all details of the order which is selected for edit</param> /// <returns>True if order updated else false</returns> public bool EditOrder(Order order) { bool status = false; var _context = new DeluxeOrderManagementEntities(); VID vid = new VID(); var announcement = (from ann in _context.AnnouncementGrids where ann.Id == order.AnnouncemntId select ann).FirstOrDefault(); var vidEty = (from vids in _context.VIDs where (vids.VendorId == order.VendorId || string.IsNullOrEmpty(vids.VendorId)) && vids.VideoVersion == announcement.VideoVersion select vids).FirstOrDefault(); if (vidEty == null) { vid.VIDStatus = "PRIMARY"; vid.VendorId = order.VendorId; vid.VideoVersion = announcement.VideoVersion; vid.TitleName = announcement.Title; vid.TitleCategory = order.OrderCategory; vid.EditName = announcement.LocalEdit; vid.CreatedOn = DateTime.UtcNow; vid.ModifiedOn = DateTime.UtcNow; vid.CreatedBy = "Deluxe"; vid.ModifiedBy = "Deluxe"; _context.VIDs.Add(vid); status = true; } else { vidEty.VendorId = order.VendorId; status = true; } var ety = _context.OrderGrids.Where(x => x.Id == order.OrderId).FirstOrDefault(); if (ety != null) { ety.RequestNumber = order.RequestNumber; ety.HALID = order.HALID; ety.MPO = order.MPO; ety.DeliveryDueDate = ParseDate(order.DueDate); ety.GreenlightSenttoPackaging = ParseDate(order.GreenlightSent); ety.GreenlightValidatedbyDMDM = ParseDate(order.GreenlightReceived); ety.ActualDeliveryDate = ParseDate(order.DeliveryDate); ety.ESTUPC = order.ESTUPC; ety.IVODUPC = order.VODUPC; ety.Category = order.OrderCategory; ety.OrderStatus = order.OrderStatus; ety.VendorId = order.VendorId; ety.FileType = order.OrderType; //ety.VIDId = (orders.Count == 1 /*|| orderExceptCurrent.Count==1*/) ? vidEty.Id : vid.Id; status = true; } if (status) { _context.SaveChanges(); if (string.IsNullOrEmpty(order.OrderStatus) || !order.OrderStatus.Equals("Other Vendor")) { _context.usp_UpdateOG_Status(order.OrderId.ToString()); } } return(status); }