public static ResultResponse Received(SouvenirRequestViewModel entity) { ResultResponse result = new ResultResponse(); try { using (var db = new MarComContext()) { T_Souvenir t_Souv = db.T_Souvenir.Where(ts => ts.Id == entity.Id).FirstOrDefault(); if (t_Souv != null) { t_Souv.Status = 3; t_Souv.Received_By = entity.Received_By; t_Souv.Received_Date = DateTime.Now; } db.SaveChanges(); result.Message = "Data Updated !! Transaction Souvenir Request with code" + entity.Code + "has been Received By Requester"; } } catch (Exception ex) { result.Success = false; result.Message = ex.Message; } return(result); }
public static List <SouvenirViewModel> Filter(SouvenirViewModel entity) { List <SouvenirViewModel> result = new List <SouvenirViewModel>(); using (var db = new MarComContext()) { result = (from s in db.M_Souvenir join u in db.M_Unit on s.M_Unit_Id equals u.Id where s.Code.Contains(entity.Code) || s.Name.Contains(entity.Name) || s.M_Unit_Id.ToString() == entity.Unit || s.Create_By.Contains(entity.Create_By) || s.Create_Date == entity.Create_Date select new SouvenirViewModel { Id = s.Id, Code = s.Code, Name = s.Name, Description = s.Description, Quantity = s.Quantity, M_Unit_Id = s.Id, Unit = u.Name, Is_Delete = s.Is_Delete, Create_By = s.Create_By, Create_Date = s.Create_Date }) .ToList(); } return(result); }
public static bool Delete(int id) { bool result = true; try { using (var db = new MarComContext()) { M_Product product = db.M_Product.Where(p => p.Id == id).FirstOrDefault(); if (product != null) { product.Is_Delete = true; db.SaveChanges(); } } } catch (Exception) { ProductRepo.GetNewCode(); return(false); } return(result); }
public static DesignRequestViewModel GetById(int id) { DesignRequestViewModel result = new DesignRequestViewModel(); using (var db = new MarComContext()) { result = (from d in db.T_Design join e in db.T_Event on d.T_Event_Id equals e.Id join em in db.M_Employee on d.Request_By equals em.Id where id == d.Id select new DesignRequestViewModel { Id = d.Id, Code = d.Code, T_Event_Id = d.T_Event_Id, EventCode = e.Code, Title_Header = d.Title_Header, Status = d.Status, Request_By = d.Request_By, NameRequest = em.First_Name + " " + em.Last_Name, Request_Date = d.Request_Date, Note = d.Note }).FirstOrDefault(); } return(result); }
public static SouvenirViewModel GetById(int id) { SouvenirViewModel result = new SouvenirViewModel(); using (var db = new MarComContext()) { result = (from s in db.M_Souvenir join u in db.M_Unit on s.M_Unit_Id equals u.Id where s.Id == id select new SouvenirViewModel { Id = s.Id, Code = s.Code, Name = s.Name, Description = s.Description, Quantity = s.Quantity, M_Unit_Id = s.M_Unit_Id, Unit = u.Name, Is_Delete = s.Is_Delete, Create_By = s.Create_By, Create_Date = s.Create_Date, }).FirstOrDefault(); } return(result); }
public static List <EmployeeViewModel> Get(bool yes) { List <EmployeeViewModel> result = new List <EmployeeViewModel>(); using (var db = new MarComContext()) { result = (from e in db.M_Employee join c in db.M_Company on e.M_Company_Id equals c.Id select new EmployeeViewModel { Id = e.Id, Employee_Number = e.Employee_Number, First_Name = e.First_Name, Last_Name = e.Last_Name, M_Company_Id = e.M_Company_Id, CompanyName = c.Name, Email = e.Email, Is_Delete = e.Is_Delete, Create_By = e.Create_By, Create_Date = DateTime.Now }) .Where(e => e.Is_Delete == yes ? e.Is_Delete : true) .ToList(); } return(result); }
//LIST public static List <DesignRequestViewModel> Get() { List <DesignRequestViewModel> result = new List <DesignRequestViewModel>(); using (var db = new MarComContext()) { result = (from dr in db.T_Design join e in db.T_Event on dr.T_Event_Id equals e.Id join em in db.M_Employee on dr.Request_By equals em.Id select new DesignRequestViewModel { Id = dr.Id, Code = dr.Code, T_Event_Id = dr.T_Event_Id, EventCode = e.Code, Request_By = dr.Request_By, NameRequest = em.First_Name + " " + em.Last_Name, Request_Date = dr.Request_Date, Assign_To = dr.Assign_To, Status = dr.Status, Is_Delete = dr.Is_Delete, Create_Date = dr.Create_Date, Create_By = dr.Create_By }).ToList(); } return(result); }
public static EventApproveViewModel GetById(int id) { EventApproveViewModel result = new EventApproveViewModel(); using (var db = new MarComContext()) { result = (from e in db.T_Event join em in db.M_Employee on e.Request_By equals em.Id where e.Id == id select new EventApproveViewModel { Id = e.Id, Code = e.Code, Event_Name = e.Event_Name, Place = e.Place, Start_Date = e.Start_Date, End_Date = e.End_Date, Budget = e.Budget, Request_By = e.Request_By, NameRequest = em.First_Name + " " + em.Last_Name, Request_Date = e.Request_Date, Note = e.Note, Status = e.Status }).FirstOrDefault(); } return(result); }
public static List <PromotionViewModel> Get() { List <PromotionViewModel> result = new List <PromotionViewModel>(); using (var db = new MarComContext()) { result = (from pr in db.T_Promotion join e in db.M_Employee on pr.Request_By equals e.Id select new PromotionViewModel { Id = pr.Id, Code = pr.Code, Request_By = pr.Request_By, RequestBy = e.First_Name + " " + e.Last_Name, Request_Date = pr.Request_Date, Assign_To = pr.Assign_To, //AssignName = e.First_Name+" "+e.Last_Name, Flag_Design = pr.Flag_Design, Status = pr.Status, Create_By = pr.Create_By, Create_Date = pr.Create_Date, Is_Delete = pr.Is_Delete }).ToList(); } return(result); }
public static List <SouvenirItemViewModel> GetItem(int id) { List <SouvenirItemViewModel> result = new List <SouvenirItemViewModel>(); using (var db = new MarComContext()) { result = (from si in db.T_Souvenir_Item join ts in db.T_Souvenir on si.T_Souvenir_Id equals ts.Id join s in db.M_Souvenir on si.M_Souvenir_Id equals s.Id where si.T_Souvenir_Id == id select new SouvenirItemViewModel { Id = si.Id, T_Souvenir_Id = si.T_Souvenir_Id, M_Souvenir_Id = si.M_Souvenir_Id, SouvenirName = s.Name, Create_By = si.Create_By, Create_Date = si.Create_Date, Qty = si.Qty, Qty_Settlement = si.Qty_Settlement, Note = si.Note, }).ToList(); } return(result); }
public static ResultResponse Approve(EventApproveViewModel entity) { ResultResponse result = new ResultResponse(); try { using (var db = new MarComContext()) { T_Event ev = db.T_Event.Where(e => e.Id == entity.Id).FirstOrDefault(); if (ev != null) { ev.Reject_Reason = entity.Reject_Reason; ev.Status = entity.Status; ev.Assign_To = entity.Assign_To; if (entity.Status == 2) { ev.Approved_Date = DateTime.Now; ev.Approved_By = entity.Approved_By; } db.SaveChanges(); } } } catch (Exception ex) { result.Success = false; result.Message = ex.Message; } return(result); }
//Ambil Id untuk Ubah status saat Approval public static ResultResponse Approved(SouvenirRequestViewModel entity) { ResultResponse result = new ResultResponse(); try { using (var db = new MarComContext()) { T_Souvenir so = db.T_Souvenir.Where(s => s.Id == entity.Id).FirstOrDefault(); if (so != null) { so.Reject_Reason = entity.Reject_Reason; so.Status = entity.Status; if (entity.Status == 2) { so.Settlement_Approved_By = entity.Settlement_Approved_By; so.Settlement_Approved_Date = DateTime.Now; } db.SaveChanges(); } } } catch (Exception ex) { result.Success = false; result.Message = ex.Message; } return(result); }
public static ResultResponse Settlement(SouvenirRequestViewModel entity, List <SouvenirItemViewModel> entityItem) { ResultResponse result = new ResultResponse(); try { using (var db = new MarComContext()) { T_Souvenir so = db.T_Souvenir.Where(sou => sou.Id == entity.Id).FirstOrDefault(); if (so != null) { so.Status = 4; so.Settlement_By = entity.Settlement_By; so.Settlement_Date = DateTime.Now; foreach (var item in entityItem) { T_Souvenir_Item si = db.T_Souvenir_Item.Where(s => s.Id == item.Id).FirstOrDefault(); si.Qty_Settlement = item.Qty_Settlement; } db.SaveChanges(); result.Message = "Data Updated !! Transaction Souvenir Request with code" + entity.Code + "has been Settled By Requester"; } } } catch (Exception ex) { result.Success = false; result.Message = ex.Message; } return(result); }
public static List <SouvenirRequestViewModel> Get() { List <SouvenirRequestViewModel> result = new List <SouvenirRequestViewModel>(); using (var db = new MarComContext()) { result = (from sr in db.T_Souvenir join e in db.M_Employee on sr.Request_By equals e.Id select new SouvenirRequestViewModel { Id = sr.Id, Code = sr.Code, Request_By = sr.Request_By, Request_Date = sr.Request_Date, Name = e.First_Name + " " + e.Last_Name, Request_Due_Date = sr.Request_Due_Date, Status = sr.Status, Is_Delete = sr.Is_Delete, Create_Date = sr.Create_Date, Create_By = sr.Create_By, }).ToList(); } return(result); }
public static string GetNewCode() { string year = DateTime.Now.ToString("yy"); string month = DateTime.Now.Month.ToString("D2"); string date = DateTime.Now.Day.ToString("D2"); string newRef = year + "." + month + "." + date + "."; using (var db = new MarComContext()) { var result = (from e in db.M_Employee where e.Employee_Number.Contains(newRef) select new { employee_number = e.Employee_Number }) .OrderByDescending(o => o.employee_number) .FirstOrDefault(); if (result != null) { string[] oldRef = result.employee_number.Split('.'); newRef += (int.Parse(oldRef[3]) + 1).ToString("D2"); } else { newRef += "01"; } return(newRef); } }
//bikin list untuk view design request public static DesignRequestViewModel GetDesReq(int id) { DesignRequestViewModel result = new DesignRequestViewModel(); using (var db = new MarComContext()) { result = (from de in db.T_Design join ev in db.T_Event on de.T_Event_Id equals ev.Id join em in db.M_Employee on de.Request_By equals em.Id //where id == de.Id where de.Id == id select new DesignRequestViewModel { Id = de.Id, T_Event_Id = de.T_Event_Id, Code = de.Code, Request_By = de.Request_By, Title_Header = de.Title_Header, NameRequest = em.First_Name + " " + em.Last_Name, Request_Date = de.Request_Date, Note = de.Note }).FirstOrDefault(); } return(result); }
public static List <EmployeeViewModel> Filter(EmployeeViewModel entity) { string date = entity.Create_Date.ToString(); string[] olddate = date.Split(' '); date = olddate[0]; List <EmployeeViewModel> result = new List <EmployeeViewModel>(); using (var db = new MarComContext()) { result = (from e in db.M_Employee join c in db.M_Company on e.M_Company_Id equals c.Id where e.Employee_Number.Contains(entity.Employee_Number) || e.First_Name.Contains(entity.FullName) && e.Last_Name.Contains(entity.FullName) || e.M_Company_Id == entity.M_Company_Id || e.Create_By.Contains(entity.Create_By) || c.Create_Date.ToString().Contains(entity.Create_Date.ToString()) select new EmployeeViewModel { Id = e.Id, Employee_Number = e.Employee_Number, First_Name = e.First_Name, Last_Name = e.Last_Name, M_Company_Id = e.M_Company_Id, CompanyName = c.Name, Create_By = e.Create_By, Create_Date = e.Create_Date }).ToList(); } return(result); }
public static PromotionViewModel GetById(int id) { PromotionViewModel result = new PromotionViewModel(); using (var db = new MarComContext()) { result = (from pr in db.T_Promotion join ev in db.T_Event on pr.T_Event_Id equals ev.Id // join de in db.T_Design on pr.T_Design_Id equals de.Id //join de in db.T_Design on pr.T_Design_Id equals de.Id join e in db.M_Employee on pr.Request_By equals e.Id where pr.Id == id select new PromotionViewModel { Id = pr.Id, Code = pr.Code, Flag_Design = pr.Flag_Design, Title = pr.Title, T_Event_Id = pr.T_Event_Id, EventCode = ev.Code, T_Design_Id = pr.T_Design_Id, // DesignCode = de.Code, //DesignCode = de.Code, Request_By = pr.Request_By, RequestBy = e.First_Name + " " + e.Last_Name, Status = pr.Status, Request_Date = pr.Request_Date, Note = pr.Note }).FirstOrDefault(); } return(result); }
public static List <MenuAccessViewModel> Get() { List <MenuAccessViewModel> result = new List <MenuAccessViewModel>(); using (var db = new MarComContext()) { result = (from ma in db.M_Menu_Access join r in db.M_Role on ma.M_Role_Id equals r.Id join m in db.M_Menu on ma.M_Menu_Id equals m.Id select new MenuAccessViewModel { Id = ma.Id, M_Role_Id = ma.M_Role_Id, RoleName = r.Name, RoleCode = r.Code, M_Menu_Id = ma.M_Menu_Id, MenuName = m.Name, Is_Delete = ma.Is_Delete, Create_By = ma.Create_By, Create_Date = DateTime.Now }).ToList(); } return(result); }
public static DesignRequestViewModel GetId(int id) { DesignRequestViewModel result = new DesignRequestViewModel(); using (var db = new MarComContext()) { result = (from dr in db.T_Design join pr in db.T_Promotion on dr.Id equals pr.T_Design_Id join em in db.M_Employee on dr.Request_By equals em.Id join di in db.T_Design_Item on dr.Id equals di.T_Design_Id where pr.Id == id select new DesignRequestViewModel { Id = dr.Id, Code = dr.Code, Title_Header = dr.Title_Header, Request_By = dr.Request_By, NameRequest = em.First_Name + "" + em.Last_Name, Request_Date = dr.Request_Date, Note = dr.Note }).FirstOrDefault(); } return(result); }
//CODE public static string GetNewCode() { string yearMonth = DateTime.Now.ToString("dd") + DateTime.Now.Month.ToString("D2") + DateTime.Now.ToString("yy"); string newRef = "TRWODS" + yearMonth + "-"; using (var db = new MarComContext()) { var result = (from dr in db.T_Design where dr.Code.Contains(newRef) select new { code = dr.Code }) .OrderByDescending(o => o.code) .FirstOrDefault(); if (result != null) { string[] oldRef = result.code.Split('-'); newRef += (int.Parse(oldRef[1]) + 1).ToString("D5"); } else { newRef += "00001"; } } return(newRef); }
public static List <PromotionItemViewModel> GetItemId(int id) { List <PromotionItemViewModel> result = new List <PromotionItemViewModel>(); using (var db = new MarComContext()) { result = (from pi in db.T_Promotion_Item join p in db.T_Promotion on pi.T_Promotion_Id equals p.Id join di in db.T_Design_Item on pi.T_Design_Item_Id equals di.Id join pr in db.M_Product on pi.M_Product_Id equals pr.Id where id == p.Id select new PromotionItemViewModel { Id = pi.Id, Title = pi.Title, M_Product_Id = pi.M_Product_Id, T_Design_Item_Id = pi.T_Design_Item_Id, ProductName = pr.Name, ProductDescription = pr.Description, Create_By = p.Create_By, Create_Date = p.Create_Date, Qty = pi.Qty, Todo = pi.Todo, Request_Due_Date = pi.Request_Due_Date, Start_Date = pi.Start_Date, End_Date = pi.End_Date, Note = pi.Note }).ToList(); } return(result); }
public static List <DesignItemViewModel> GetCloseItem(int id) { List <DesignItemViewModel> result = new List <DesignItemViewModel>(); using (var db = new MarComContext()) { result = (from di in db.T_Design_Item join td in db.T_Design on di.T_Design_Id equals td.Id join p in db.M_Product on di.M_Product_Id equals p.Id join df in db.T_Design_Item_File on di.Id equals df.T_Design_Item_Id where di.T_Design_Id == id select new DesignItemViewModel { Id = di.Id, T_Design_Id = di.T_Design_Id, M_Product_Id = di.M_Product_Id, ProductName = p.Name, Description = p.Description, Title_Item = di.Title_Item, Request_Pic = di.Request_Pic, Request_Due_Date = di.Request_Due_Date, Start_Date = di.Start_Date, End_Date = di.End_Date, Note = di.Note }).ToList(); } return(result); }
//Untuk Mengambil Data berdasarkan Id untuk PromotionItemFile public static List <PromotionItemFileViewModel> GetIdFile(int id) { List <PromotionItemFileViewModel> result = new List <PromotionItemFileViewModel>(); using (var db = new MarComContext()) { result = (from it in db.T_Promotion_Item_File join p in db.T_Promotion on it.T_Promotion_id equals p.Id where id == p.Id select new PromotionItemFileViewModel { Id = it.Id, Filename = it.Filename, Qty = it.Qty, Todo = it.Todo, Request_Due_Date = it.Request_Due_Date, Start_Date = it.Start_Date, End_Date = it.End_Date, Note = it.Note } ).ToList(); } return(result); }
public static List <SouvenirViewModel> Get(bool all) { List <SouvenirViewModel> result = new List <SouvenirViewModel>(); using (var db = new MarComContext()) { result = (from s in db.M_Souvenir join u in db.M_Unit on s.M_Unit_Id equals u.Id select new SouvenirViewModel { Id = s.Id, Code = s.Code, Name = s.Name, Description = s.Description, Quantity = s.Quantity, M_Unit_Id = s.M_Unit_Id, Unit = u.Name, Is_Delete = s.Is_Delete, Create_By = s.Create_By, Create_Date = s.Create_Date }) .Where(s => s.Is_Delete == all ? s.Is_Delete : true) .ToList(); } return(result); }
//Ambil Id untuk Ubah status saat Approval public static ResultResponse Approve(PromotionViewModel entity) { ResultResponse result = new ResultResponse(); try { using (var db = new MarComContext()) { T_Promotion pr = db.T_Promotion.Where(p => p.Id == entity.Id).FirstOrDefault(); if (pr != null) { pr.Reject_Reason = entity.Reject_Reason; pr.Status = entity.Status; pr.Assign_To = entity.Assign_To; if (entity.Status == 2) { pr.Approved_By = entity.Approved_By; pr.Approved_Date = DateTime.Now; } db.SaveChanges(); } } } catch (Exception ex) { result.Success = false; result.Message = ex.Message; } return(result); }
public static List <UserViewModel> Get() { List <UserViewModel> result = new List <UserViewModel>(); using (var db = new MarComContext()) { result = (from us in db.M_User join em in db.M_Employee on us.M_Employee_Id equals em.Id join r in db.M_Role on us.M_Role_Id equals r.Id //where u.Is_Delete == false select new UserViewModel { Id = us.Id, M_Employee_Id = us.M_Employee_Id, Fullname = em.First_Name + " " + em.Last_Name, M_Role_Id = us.M_Role_Id, Role = r.Name, // Company = em, Username = us.Username, Password = us.Password, Is_Delete = us.Is_Delete, Create_By = us.Create_By, Create_Date = DateTime.Now }).ToList(); } return(result); }
public static ResultResponse UploadItem(PromotionItemFileViewModel entity) { ResultResponse result = new ResultResponse(); try { using (var db = new MarComContext()) { if (entity.Id == 0) { T_Promotion_Item_File it = new T_Promotion_Item_File(); it.Id = it.Id; it.Filename = it.Filename; it.Qty = it.Qty; it.Todo = it.Todo; it.Request_Due_Date = it.Request_Due_Date; it.Note = it.Note; it.Create_By = it.Create_By; it.Create_Date = DateTime.Now; db.T_Promotion_Item_File.Add(it); db.SaveChanges(); } } } catch (Exception) { throw; } return(result); }
public static List <MenuViewModel> Get(bool all) { List <MenuViewModel> result = new List <MenuViewModel>(); using (var db = new MarComContext()) { result = (from m in db.M_Menu where m.Parent_Id != null select new MenuViewModel { Id = m.Id, Code = m.Code, Name = m.Name, Controller = m.Controller, Parent_Id = m.Parent_Id, Is_Delete = m.Is_Delete, Create_By = m.Create_By, Create_Date = m.Create_Date, }) .Where(m => m.Is_Delete == all ? m.Is_Delete : true) .ToList(); } return(result); }
public static ResultResponse Approve(SouvenirRequestViewModel entity) { ResultResponse result = new ResultResponse(); try { using (var db = new MarComContext()) { T_Souvenir souv = db.T_Souvenir.Where(s => s.Id == entity.Id).FirstOrDefault(); if (souv != null) { souv.Reject_Reason = entity.Reject_Reason; souv.Status = entity.Status; result.Message = "Data Rejected !! Transaction Souvenir Request with code " + entity.Code + " is rejected by Administrator"; if (entity.Status == 2) { souv.Approve_Date = DateTime.Now; souv.Approved_By = entity.Approved_By; result.Message = "Data Approved !! Transaction Souvenir Request with code " + entity.Code + " has been approved."; } db.SaveChanges(); } } } catch (Exception ex) { result.Success = false; result.Message = ex.Message; } return(result); }