public static ClientModel getClientbyId(int id) { try { using (HJStudioEntities context = new HJStudioEntities()) { return(context.ClientMasters.Where(x => x.ClientID == id).Select(x => new ClientModel { ClientID = x.ClientID, Name = x.Name, Address1 = x.Address1, Address2 = x.Address2, City = x.City, State = x.State, EmailId = x.EmailId, MobileNo = x.MobileNo, CreatedBy = x.CreatedBy, ModifiedBy = x.ModifiedBy, Refrence = x.Refrence }).FirstOrDefault()); } } catch (Exception ex) { return(null); } }
public static LogedUserDetails CheckLogin(LoginModel model) { try { using (HJStudioEntities db = new HJStudioEntities()) { return(new LogedUserDetails { EmployeeID = 1, Name = "Kishan", EmailId = "*****@*****.**", }); return(db.EmployeeMasters.Where(x => x.EmailId == model.EmailId && x.Password.Equals(model.UserPassword)).Select(x => new LogedUserDetails { EmployeeID = x.EmployeeID, Name = x.Name, EmailId = x.EmailId, }).FirstOrDefault()); } } catch (Exception) { return(null); } }
public static EmployeeModel getEmployeebyId(int id) { try { using (HJStudioEntities context = new HJStudioEntities()) { return(context.EmployeeMasters.Where(x => x.EmployeeID == id).Select(x => new EmployeeModel { EmployeeID = x.EmployeeID, Name = x.Name, Address1 = x.Address1, Address2 = x.Address2, City = x.City, State = x.State, EmailId = x.EmailId, MobileNo = x.MobileNo, UserType = x.UserType, Password = x.Password, DailyWages = x.DailyWages, HalfDayWages = x.HalfDayWages, MonthlyWages = x.MonthlyWages, CreatedBy = x.CreatedBy, ModifiedBy = x.ModifiedBy, WagesType = x.WagesType, //cdate = x.CreatedDate != null ? x.CreatedDate.Value.ToString("dd-MM-yyyy") : "", //mdate = x.ModifiedDate != null ? x.ModifiedDate.Value.ToString("dd-MM-yyyy") : "", Status = x.Status }).FirstOrDefault()); } } catch (Exception ex) { return(null); } }
public static bool DeleteClient(int id) { try { using (HJStudioEntities context = new HJStudioEntities()) { ClientMaster TblUser = new ClientMaster(); var temp = context.ClientMasters.Find(id); TblUser = temp == null ? new ClientMaster() : temp; if (temp == null) { return(false); } context.ClientMasters.Remove(TblUser); context.SaveChanges(); return(true); } } catch (Exception ex) { return(false); } }
public static EnquiryModel getEnquirybyId(int id) { try { using (HJStudioEntities context = new HJStudioEntities()) { return((from ED in context.FunctionDetails join CI in context.ClientMasters on ED.ClientId equals CI.ClientID select new { ED, CI }).ToList().Select(x => new EnquiryModel { Id = x.ED.Id, FunctionName = x.ED.FunctionName, FunctionDescription = x.ED.FunctionDescription, FunctionDate = x.ED.FunctionDate, City = x.ED.City, State = x.ED.State, client = new ClientModel() { Name = x.CI.Name, MobileNo = x.CI.MobileNo, EmailId = x.CI.EmailId, Refrence = x.CI.Refrence, Address1 = x.CI.Refrence, Address2 = x.CI.Refrence, City = x.CI.City, State = x.CI.State } }).FirstOrDefault()); } } catch (Exception ex) { return(null); } }
public static List <ClientModel> getActiveClientList() { try { using (HJStudioEntities context = new HJStudioEntities()) { return(context.ClientMasters.Select(x => new ClientModel { ClientID = x.ClientID, Name = x.Name, Address1 = x.Address1, Address2 = x.Address2, City = x.City, State = x.State, EmailId = x.EmailId, MobileNo = x.MobileNo, CreatedBy = x.CreatedBy, ModifiedBy = x.ModifiedBy, Refrence = x.Refrence }).ToList()); } } catch (Exception ex) { return(null); } }
public static bool DeleteProduct(int id) { try { using (HJStudioEntities context = new HJStudioEntities()) { ProductMaster prod = new ProductMaster(); var temp = context.ProductMasters.Find(id); prod = temp == null ? new ProductMaster() : temp; if (temp == null) { return(false); } context.ProductMasters.Remove(prod); context.SaveChanges(); return(true); } } catch (Exception ex) { return(false); } }
public static int AddEditUserMenu(MenuModel _model) { try { using (HJStudioEntities context = new HJStudioEntities()) { context.MenuUserAllocations.Where(x => x.UserId == _model.UserId).ToList().ForEach(x => { context.MenuUserAllocations.Remove(x); }); foreach (var Mid in _model.MenuIdList) { if (Mid > 0) { MenuUserAllocation _MenuUserAllocationTable = new MenuUserAllocation(); _MenuUserAllocationTable.UserId = _model.UserId; _MenuUserAllocationTable.MenuId = Mid; context.MenuUserAllocations.Add(_MenuUserAllocationTable); } } context.SaveChanges(); return(_model.UserId.Value); } } catch (Exception) { throw; } }
public static bool AddProduct(ProductModel model) { try { using (HJStudioEntities context = new HJStudioEntities()) { ProductMaster prod = new ProductMaster(); var temp = context.ProductMasters.Find(model.ProductId); prod = temp == null ? new ProductMaster() : temp; prod.ProductName = model.ProductName; prod.ProductDescription = model.ProductDescription; prod.Amount = model.Amount; if (temp == null) { prod.CreatedBy = "Admin"; prod.CreatedDate = DateTime.Now; context.ProductMasters.Add(prod); } else { prod.ModifiedBy = "Admin"; prod.ModifiedDate = DateTime.Now; } context.SaveChanges(); return(true); } } catch (Exception) { return(false); } }
public static List <EmployeeModel> getEmployeeList() { try { using (HJStudioEntities context = new HJStudioEntities()) { return(context.EmployeeMasters.Where(x => x.Status == 1).Select(x => new EmployeeModel { EmployeeID = x.EmployeeID, Name = x.Name, Address1 = x.Address1, Address2 = x.Address2, City = x.City, State = x.State, EmailId = x.EmailId, MobileNo = x.MobileNo, UserType = x.UserType, Password = x.Password, DailyWages = x.DailyWages, HalfDayWages = x.HalfDayWages, MonthlyWages = x.MonthlyWages, CreatedBy = x.CreatedBy, ModifiedBy = x.ModifiedBy, Status = x.Status }).ToList()); } } catch (Exception ex) { return(null); } }
public static JsTree3Node GetMenuTreeByUser(int?UserId) { try { using (HJStudioEntities db = new HJStudioEntities()) { int Cid = 0; var user = db.EmployeeMasters.Find(UserId); if (user.UserType == (int)UserType.Admin) { Cid = user.UserType ?? 0; } else { Cid = 0; } // var admin = CommonService.GetFranchiseeAdmin(Cid); int?adminId = CommanModel.LoginUserDetails.EmployeeID; //if (admin != null) //{ // adminId = admin.UserId; //} var root = new JsTree3Node() { id = "0", text = "HJ", state = new JsTree3Node.State(true, false, false) }; var children1 = new List <JsTree3Node>(); List <int> list = db.MenuUserAllocations.Where(x => x.UserId == UserId).Select(x => x.MenuId ?? 0).ToList(); var menu = db.MenuMasters.Where(x => x.MenuUserAllocations.Any(y => (y.UserId == adminId || adminId == 0))); foreach (var item in menu.Where(x => x.ParentID == null).ToList()) { var chields = menu.Where(x => x.ParentID == item.MenuID).ToList(); var node = (list.Contains(item.MenuID) && (chields == null || chields.Count == 0)) ? JsTree3Node.NewNode(item.MenuID, item.MenuName, true) : JsTree3Node.NewNode(item.MenuID, item.MenuName, false); foreach (var itemChild in chields) { bool ChildSel = list.Contains(itemChild.MenuID); node.children.Add(JsTree3Node.NewNode(itemChild.MenuID, itemChild.MenuName, ChildSel)); } node.state.opened = false; children1.Add(node); } root.children = children1; return(root); // return Json(root, JsonRequestBehavior.AllowGet); } } catch (Exception) { throw; } }
public static List <EmployeeModel> EmployeeNameList() { try { using (HJStudioEntities context = new HJStudioEntities()) { return(context.EmployeeMasters.Select(x => new EmployeeModel { EmployeeID = x.EmployeeID, Name = x.Name }).ToList()); } } catch (Exception) { return(null); } }
public static List <ClientModel> clientIDList() { try { using (HJStudioEntities context = new HJStudioEntities()) { return(context.ClientMasters.Select(x => new ClientModel { ClientID = x.ClientID, Name = x.Name }).ToList()); } } catch (Exception) { return(null); } }
public static bool AddEmployee(EmployeeModel model) { try { using (HJStudioEntities context = new HJStudioEntities()) { EmployeeMaster emp = new EmployeeMaster(); var temp = context.EmployeeMasters.Find(model.EmployeeID); emp = temp == null ? new EmployeeMaster() : temp; emp.Name = model.Name; emp.Address1 = model.Address1; emp.Address2 = model.Address2; emp.EmailId = model.EmailId; emp.MobileNo = model.MobileNo; emp.City = model.City; emp.State = model.State; emp.Password = model.Password; emp.UserType = model.UserType; emp.DailyWages = model.DailyWages; emp.HalfDayWages = model.HalfDayWages; emp.MonthlyWages = model.MonthlyWages; emp.WagesType = model.WagesType; if (temp == null) { emp.CreatedBy = "Admin"; emp.CreatedDate = DateTime.Now; emp.Status = 1; context.EmployeeMasters.Add(emp); } else { emp.ModifiedBy = "Admin"; emp.ModifiedDate = DateTime.Now; } context.SaveChanges(); return(true); } } catch (Exception) { return(false); } }
public static List <ProductModel> getActiveProductList() { try { using (HJStudioEntities context = new HJStudioEntities()) { return(context.ProductMasters.Select(x => new ProductModel { ProductId = x.ProductId, ProductName = x.ProductName, ProductDescription = x.ProductDescription, Amount = x.Amount, }).ToList()); } } catch (Exception ex) { return(null); } }
public static List <MenuModel> GetAllUserMenuDataBYRole() { try { using (HJStudioEntities context = new HJStudioEntities()) { //int cid = CommonModel.LoginUserDetails.FranchiseeId; //var admin = CommonService.GetFranchiseeAdmin(cid); //List<int> list = CommonService.GetFranchiseeAndChildFranchisee(); return(context.EmployeeMasters.Where(x => x.Status == 1).Select(x => new MenuModel { UserId = x.EmployeeID, UserName = x.Name }).OrderByDescending(x => x.UserId).ToList()); } } catch (Exception) { throw; } }
public static List <CalendarModel> GetCalanderFollowup() { try { using (HJStudioEntities context = new HJStudioEntities()) { //var LIST = context.FunctionDetails.ToList().Select(x => new CalendarModel //{ // id = x.Id, // title = x.FunctionName, // start = x.FunctionDate != null ? x.FunctionDate.Value.ToString("yyyy-MM-dd hh:mm") : "", // end = x.FunctionDate != null ? x.FunctionDate.Value.ToString("yyyy-MM-dd hh:mm") : "", // description = x.FunctionDescription, // className = "m-fc-event--solid-info m-fc-event--light", // url = "javascript:addfollowup(" + x.Id + ");" //}).ToList(); //return LIST; return((from E in context.EnquiryFollowUps join F in context.FunctionDetails on E.EnquiryId equals F.Id group E by E.EnquiryId into G select G).ToList().Select(G => new CalendarModel { id = G.Key ?? 0, title = G.OrderByDescending(x => x.EnquiryFollowupId).Select(x => x.FunctionDetail.FunctionName).FirstOrDefault(), start = G.OrderByDescending(x => x.EnquiryFollowupId).Select(x => x.NextFolowupDate == null ? "" : x.NextFolowupDate.Value.ToString("yyyy-MM-ddThh:mm:ss")).FirstOrDefault(), //"2019-08-01T11:15:00", end = G.OrderByDescending(x => x.EnquiryFollowupId).Select(x => x.NextFolowupDate == null ? "" : x.NextFolowupDate.Value.ToString("yyyy-MM-ddThh:mm:ss")).FirstOrDefault(), //"2019-08-01T11:15:00", description = G.OrderByDescending(x => x.EnquiryFollowupId).Select(x => x.Remarks).FirstOrDefault() ?? "", className = "m-fc-event--primary", url = "javascript:addfollowup(" + G.Key + ");" }).ToList()); } } catch (Exception) { return(null); } }
public static bool AddClient(ClientModel model) { try { using (HJStudioEntities context = new HJStudioEntities()) { ClientMaster clt = new ClientMaster(); var temp = context.ClientMasters.Find(model.ClientID); clt = temp == null ? new ClientMaster() : temp; clt.Name = model.Name; clt.MobileNo = model.MobileNo; clt.EmailId = model.EmailId; clt.Address1 = model.Address1; clt.Address2 = model.Address2; clt.City = model.City; clt.State = model.State; clt.Refrence = model.Refrence; if (temp == null) { clt.CreatedBy = "Admin"; clt.CreatedDate = DateTime.Now; context.ClientMasters.Add(clt); } else { clt.ModifiedBy = "Admin"; clt.ModifiedDate = DateTime.Now; } context.SaveChanges(); return(true); } } catch (Exception) { return(false); } }
public static bool AddExpense(ExpenseModel model) { try { using (HJStudioEntities context = new HJStudioEntities()) { Expense exp = new Expense(); var temp = context.Expenses.Find(model.ExpenseID); exp = temp == null ? new Expense() : temp; exp.Description = model.Description; exp.EmployeeID = model.EmployeeID; exp.BankName = model.BankName; exp.IsBank = model.IsBank; exp.IFSCCode = model.IFSCCode; exp.ChequeNo = model.ChequeNo; exp.Amount = model.Amount; if (temp == null) { exp.CreatedBy = "Admin"; exp.CreatedDate = DateTime.Now; context.Expenses.Add(exp); } else { exp.Modifiedby = "Admin"; exp.ModifiedDate = DateTime.Now; } context.SaveChanges(); return(true); } } catch (Exception) { return(false); } }
public static ProductModel getProductbyId(int id) { try { using (HJStudioEntities context = new HJStudioEntities()) { return(context.ProductMasters.Where(x => x.ProductId == id).Select(x => new ProductModel { ProductId = x.ProductId, ProductName = x.ProductName, ProductDescription = x.ProductDescription, Amount = x.Amount, CreatedBy = x.CreatedBy, ModifiedBy = x.ModifiedBy, CreatedDate = x.CreatedDate }).FirstOrDefault()); } } catch (Exception ex) { return(null); } }
public static List <EnquiryFollowUpModel> GetInquiryFollowupByInquiryId(int Id) { try { using (HJStudioEntities db = new HJStudioEntities()) { return(db.EnquiryFollowUps.Where(x => x.EnquiryId == Id).OrderByDescending(x => x.EnquiryFollowupId).ToList().Select(x => new EnquiryFollowUpModel { InquiryFollowupId = x.EnquiryFollowupId, InquiryId = x.EnquiryId, Remarks = x.Remarks, NextFolowupDate = x.NextFolowupDate, InquiryStatusString = Enum.GetName(typeof(Enquirytype), x.EnquiryStatus), CreatedBy = x.CreatedBy, CreatedDate = x.CreatedDate, }).ToList()); } } catch (Exception) { throw; } }
public static bool ActivatetEmployee(int id) { try { using (HJStudioEntities context = new HJStudioEntities()) { EmployeeMaster TblUser = new EmployeeMaster(); var temp = context.EmployeeMasters.Find(id); TblUser = temp == null ? new EmployeeMaster() : temp; TblUser.Status = 1; if (temp == null) { return(false); } context.SaveChanges(); return(true); } } catch (Exception ex) { return(false); } }
public static ExpenseModel getExpensebyId(int id) { try { using (HJStudioEntities context = new HJStudioEntities()) { return(context.Expenses.Where(x => x.ExpenseID == id).Select(x => new ExpenseModel { Description = x.Description, EmployeeID = x.EmployeeID, BankName = x.BankName, IsBank = x.IsBank ?? false, ChequeNo = x.ChequeNo, IFSCCode = x.IFSCCode, Amount = x.Amount, CreatedBy = x.CreatedBy }).FirstOrDefault()); } } catch (Exception ex) { return(null); } }
public static QuotationModel getQuotationbyId(int id) { try { using (HJStudioEntities context = new HJStudioEntities()) { var data = context.QuotationMasters.Where(x => x.QuotationID == id).Select(x => new QuotationModel { QuotationID = x.QuotationID, QuotationDate = x.QuotationDate, EventStartDate = x.EventStartDate, EventDays = x.EventDays, Remark = x.Remark, QuotationAmount = x.QuotationAmount, Discount = x.Discount, FinalAmount = x.FinalAmount, ClientID = x.ClientID, Name = x.Name, MobileNo = x.MobileNo, EmailId = x.EmailId, Address1 = x.Address1, Address2 = x.Address2, City = x.City, State = x.State, Refrence = x.Refrence, Status = x.Status, }).FirstOrDefault(); return(data); } } catch (Exception ex) { return(null); } }
public static int EnquiryFollowUpModel(EnquiryFollowUpModel model) { try { using (HJStudioEntities context = new HJStudioEntities()) { EnquiryFollowUp ef = new EnquiryFollowUp(); //var temp1 = context.EnquiryFollowUps.Find(model.InquiryId); // ef = temp1 == null ? new EnquiryFollowUp() : temp1; ef.EnquiryId = model.InquiryId; ef.EnquiryStatus = model.InquiryStatus; ef.Remarks = model.Remarks; ef.NextFolowupDate = model.NextFolowupDate; context.EnquiryFollowUps.Add(ef); context.SaveChanges(); } return(1); } catch (Exception) { return(0); } }
public static List <MenuModel> GetMenuList(string Search, int startIndex, int endIndex, int sortColumnIndex, string sortDirection, out int Total) { try { using (HJStudioEntities context = new HJStudioEntities()) { Total = 0; //int cid = CommonModel.LoginUserDetails.FranchiseeId; //var admin = CommonService.GetFranchiseeAdmin(cid); //List<int> Flist = CommonService.GetFranchiseeAndChildFranchisee(); var list = context.EmployeeMasters.Where(x => x.Status == 1).Select(x => new MenuModel { UserId = x.EmployeeID, UserName = x.Name }).ToList(); if (sortColumnIndex > 0) { if (sortDirection == "desc") { switch (sortColumnIndex) { case 1: list = list.OrderByDescending(x => x.UserName).ToList(); break; case 2: list = list.OrderByDescending(x => x.FranchiseeName).ToList(); break; } } if (sortDirection == "asc") { switch (sortColumnIndex) { case 1: list = list.OrderBy(x => x.UserName).ToList(); break; case 2: list = list.OrderBy(x => x.FranchiseeName).ToList(); break; } } } else { list = list.OrderByDescending(x => x.UserId).ToList(); } if (!string.IsNullOrEmpty(Search)) { Search = Search.ToLower(); list = list.Where(x => (x.UserName != null ? x.UserName.ToLower().Contains(Search) : true) || (x.FranchiseeName != null ? x.FranchiseeName.ToLower().Contains(Search) : true) ).ToList(); } Total = list != null?list.Count() : 0; list = list.Skip(startIndex).Take(endIndex).ToList(); return(list); } } catch (Exception) { Total = 0; return(null); } }
public static List <JsTree3Node> GetUserMenu(int?UserId) { try { using (HJStudioEntities db = new HJStudioEntities()) { var User = db.EmployeeMasters.Find(UserId); var children1 = new List <JsTree3Node>(); if (User.UserType != (int)UserType.User) { List <int> list = db.MenuUserAllocations.Where(x => x.UserId == UserId).Select(x => x.MenuId ?? 0).ToList(); foreach (var item in db.MenuMasters.Where(x => x.ParentID == null).OrderBy(x => x.DisplayOrder).ToList()) { var chields = db.MenuMasters.Where(x => x.ParentID == item.MenuID && list.Contains(x.MenuID)).OrderBy(x => x.DisplayOrder).ToList(); if (chields != null && chields.Count() > 0) { var node = JsTree3Node.NewNode(item.MenuID, item.MenuName, false, item.MenuLink, item.MenuIcon); foreach (var itemChild in chields) { node.children.Add(JsTree3Node.NewNode(itemChild.MenuID, itemChild.MenuName, false, itemChild.MenuLink, itemChild.MenuIcon)); } node.state.opened = false; children1.Add(node); } else if (list.Contains(item.MenuID)) { var node = JsTree3Node.NewNode(item.MenuID, item.MenuName, true, item.MenuLink, item.MenuIcon); node.state.opened = false; children1.Add(node); } } } else { foreach (var item in db.MenuMasters.Where(x => x.ParentID == null).OrderBy(x => x.DisplayOrder).ToList()) { var chields = db.MenuMasters.Where(x => x.ParentID == item.MenuID && x.IsForEmployee == true).OrderBy(x => x.DisplayOrder).ToList(); if (chields != null && chields.Count() > 0) { var node = JsTree3Node.NewNode(item.MenuID, item.MenuName, false, item.MenuLink, item.MenuIcon); foreach (var itemChild in chields) { node.children.Add(JsTree3Node.NewNode(itemChild.MenuID, itemChild.MenuName, false, itemChild.MenuLink, itemChild.MenuIcon)); } node.state.opened = false; children1.Add(node); } else if (item.IsForEmployee == true) { var node = JsTree3Node.NewNode(item.MenuID, item.MenuName, true, item.MenuLink, item.MenuIcon); node.state.opened = false; children1.Add(node); } } } return(children1); } } catch (Exception) { throw; } }
public static List <QuotationModel> LoadQuotationDetail(string Search, int startIndex, int endIndex, int sortColumnIndex, string sortDirection, out int Total) { try { using (HJStudioEntities context = new HJStudioEntities()) { Total = 0; var list = context.QuotationMasters.ToList().Select(x => new QuotationModel { QuotationDate = x.QuotationDate, QuotationDateStr = x.QuotationDate != null ? x.QuotationDate.Value.ToString("dd-MM-yyyy") : "", EventStartDate = x.EventStartDate, EventDays = x.EventDays, Remark = x.Remark, QuotationAmount = x.QuotationAmount, Discount = x.Discount, FinalAmount = x.FinalAmount, ClientID = x.ClientID, Name = x.Name, MobileNo = x.MobileNo, EmailId = x.EmailId, Address1 = x.Address1, Address2 = x.Address2, City = x.City, State = x.State, Refrence = x.Refrence, Status = x.Status, }).ToList(); if (sortColumnIndex > 0) { if (sortDirection == "desc") { switch (sortColumnIndex) { case 1: list = list.OrderByDescending(x => x.QuotationDate).ToList(); break; case 2: list = list.OrderByDescending(x => x.Name).ToList(); break; case 3: list = list.OrderByDescending(x => x.MobileNo).ToList(); break; } } if (sortDirection == "asc") { switch (sortColumnIndex) { case 1: list = list.OrderBy(x => x.QuotationDate).ToList(); break; case 2: list = list.OrderBy(x => x.Name).ToList(); break; case 3: list = list.OrderBy(x => x.MobileNo).ToList(); break; } } } else { list = list.OrderByDescending(x => x.QuotationID).ToList(); } if (!string.IsNullOrEmpty(Search)) { Search = Search.ToLower(); list = list.Where(x => (x.QuotationDateStr != null ? x.QuotationDateStr.ToLower().Contains(Search) : true) || (x.Name != null ? x.Name.ToLower().Contains(Search) : true) || (x.MobileNo != null ? x.MobileNo.Equals(Search) : true) ).ToList(); } Total = list != null?list.Count() : 0; list = list.Skip(startIndex).Take(endIndex).ToList(); return(list); } } catch (Exception) { Total = 0; return(null); } }
public static bool AddQuotation(QuotationModel model) { try { using (HJStudioEntities context = new HJStudioEntities()) { ClientMaster clt = new ClientMaster(); var Clienttemp = context.ClientMasters.Find(model.ClientID); clt = Clienttemp == null ? new ClientMaster() : Clienttemp; clt.Name = model.Name; clt.MobileNo = model.MobileNo; clt.EmailId = model.EmailId; clt.Address1 = model.Address1; clt.Address2 = model.Address2; clt.City = model.City; clt.State = model.State; clt.Refrence = model.Refrence; if (Clienttemp == null) { clt.CreatedBy = "Admin"; clt.CreatedDate = DateTime.Now; context.ClientMasters.Add(clt); } else { clt.ModifiedBy = "Admin"; clt.ModifiedDate = DateTime.Now; } context.SaveChanges(); int ClientID = clt.ClientID; QuotationMaster _Quotation = new QuotationMaster(); var temp = context.QuotationMasters.Find(model.QuotationID); _Quotation = temp == null ? new QuotationMaster() : temp; if (temp != null) { } _Quotation.QuotationDate = model.QuotationDate; _Quotation.EventStartDate = model.EventStartDate; _Quotation.EventDays = model.EventDays; _Quotation.Remark = model.Remark; _Quotation.QuotationAmount = model.QuotationAmount; _Quotation.Discount = model.Discount; _Quotation.FinalAmount = model.FinalAmount; _Quotation.ClientID = ClientID; _Quotation.Name = model.Name; _Quotation.MobileNo = model.MobileNo; _Quotation.EmailId = model.EmailId; _Quotation.Address1 = model.Address1; _Quotation.Address2 = model.Address2; _Quotation.City = model.City; _Quotation.State = model.State; _Quotation.Refrence = model.Refrence; _Quotation.Status = model.Status; List <QuotationDay> _QuotationDay = new List <Data.QuotationDay>(); if (model.QuotationDayList != null) { foreach (var d in model.QuotationDayList) { List <EmployeeQuotationDay> _EmployeeQuotationDay = new List <EmployeeQuotationDay>(); if (d.EmployeeQuotationDayList != null) { foreach (var e in d.EmployeeQuotationDayList) { if (e.IsDelete == false && e.EmployeeID > 0) { _EmployeeQuotationDay.Add(new EmployeeQuotationDay { EmployeeID = e.EmployeeID, Wages = e.Wages, EmployeeRole = e.EmployeeRole, }); } } } _QuotationDay.Add(new QuotationDay { EventName = d.EventName, EventDate = d.EventDate, StartTime = d.StartTime, EndTime = d.EndTime, Remarks = d.Remarks, Address1 = d.Address1, Address2 = d.Address2, City = d.City, State = d.State, ClientMobileNo = d.ClientMobileNo, EmployeeQuotationDays = _EmployeeQuotationDay }); } } _Quotation.QuotationDays = _QuotationDay; List <ProductQuotation> _ProductQuotation = new List <ProductQuotation>(); if (model.ProductQuotationList != null) { foreach (var p in model.ProductQuotationList) { if (p.ProductID > 0) { _ProductQuotation.Add(new ProductQuotation { ProductID = p.ProductID, Quantity = p.Quantity, Amount = p.Amount, TotalAmount = p.TotalAmount, Remark = p.Remark, }); } } } _Quotation.ProductQuotations = _ProductQuotation; if (temp == null) { _Quotation.CreatedBy = CommanModel.LoginUserDetails.EmployeeID; _Quotation.CreatedDate = DateTime.Now; context.QuotationMasters.Add(_Quotation); } else { _Quotation.ModifiedBy = CommanModel.LoginUserDetails.EmployeeID; _Quotation.ModifiedDate = DateTime.Now; } context.SaveChanges(); return(true); } } catch (Exception) { return(false); } }
public static List <EnquiryModel> LoadEnquiryDetail(string Search, int startIndex, int endIndex, int sortColumnIndex, string sortDirection, out int Total) { try { using (HJStudioEntities context = new HJStudioEntities()) { Total = 0; var list = (from ED in context.FunctionDetails join CI in context.ClientMasters on ED.ClientId equals CI.ClientID select new { ED, CI }).ToList().Select(x => new EnquiryModel { Id = x.ED.Id, FunctionName = x.ED.FunctionName, FunctionDescription = x.ED.FunctionDescription, FunctionDate = x.ED.FunctionDate, City = x.ED.City, State = x.ED.State, client = new ClientModel() { Name = x.CI.Name, MobileNo = x.CI.MobileNo, EmailId = x.CI.EmailId, Refrence = x.CI.Refrence, Address1 = x.CI.Refrence, Address2 = x.CI.Refrence, City = x.CI.City, State = x.CI.State } }).ToList(); if (sortColumnIndex > 0) { if (sortDirection == "desc") { switch (sortColumnIndex) { case 1: list = list.OrderByDescending(x => x.FunctionName).ToList(); break; case 2: list = list.OrderByDescending(x => x.client.Name).ToList(); break; case 3: list = list.OrderByDescending(x => x.City).ToList(); break; case 4: list = list.OrderByDescending(x => x.State).ToList(); break; } } if (sortDirection == "asc") { switch (sortColumnIndex) { case 1: list = list.OrderBy(x => x.FunctionName).ToList(); break; case 2: list = list.OrderBy(x => x.client.Name).ToList(); break; case 3: list = list.OrderBy(x => x.City).ToList(); break; case 4: list = list.OrderBy(x => x.State).ToList(); break; } } } else { list = list.OrderByDescending(x => x.Id).ToList(); } if (!string.IsNullOrEmpty(Search)) { Search = Search.ToLower(); list = list.Where(x => (x.FunctionName != null ? x.FunctionName.Contains(Search) : true) || (x.City != null ? x.City.ToLower().Contains(Search) : true) || (x.client.Name != null ? x.client.Name.ToLower().Contains(Search) : true) || // (x.FunctionDate != null ? x.FunctionDate.ToString().Contains(Search) : true) || (x.client.MobileNo != null ? x.client.MobileNo.ToLower().Contains(Search) : true) // (x.CreatedBy != null ? x.CreatedBy.ToLower().Contains(Search) : true) //(x.UserType != null ? x.UserType == Search : true) ).ToList(); } Total = list != null?list.Count() : 0; list = list.Skip(startIndex).Take(endIndex).ToList(); return(list); } } catch (Exception) { Total = 0; return(null); } }