public ActionResult GetProductToDay() { var todayCodde = ConvertDate.TotalSeconds(DateTime.Today); var lst = _orderDa.GetProductToDay(todayCodde); return(Json(lst)); }
public ActionResult LogOn(LogOnModel model) { var returnUrl = Request["itemUrl"].Replace("/Account/LogOn", ""); var code = ConvertDate.TotalSeconds(DateTime.Now).ToString(); var obj = _dnLoginApi.CustomerLogin(code, model.UserName, model.Password, model.RememberMe); if (obj != null && obj.ID != 0) { #region Cookie CodeLogin var expires = model.RememberMe ? DateTime.Now.AddDays(1) : DateTime.Now.AddMinutes(20); var codeCookie = HttpContext.Request.Cookies["CusLogin"]; if (codeCookie == null) { codeCookie = new HttpCookie("CusLogin") { Value = code, Expires = expires }; Response.Cookies.Add(codeCookie); } else { codeCookie.Value = code; codeCookie.Expires = expires; Response.Cookies.Add(codeCookie); } #endregion return(Redirect("/")); } ModelState.AddModelError("", string.Format("{0}Tên người dùng hoặc mật khẩu được cung cấp là không chính xác.", "")); return(View(model)); }
public SWItem GetStorageByID(int agencyId, int id) { var date = ConvertDate.TotalSeconds(DateTime.Now.AddHours(12)); var query = from o in FDIDB.StorageWarehousings where o.AgencyId == agencyId && (!o.IsDelete.HasValue || !o.IsDelete.Value) && o.ID == id select new SWItem { id = o.ID, n = o.Name, c = o.Code, d = o.DateRecive ?? 0, LstItem = o.DN_RequestWare.Select(m => new DNRWHItem { n = m.Category.Name, h = m.Hour ?? 0, c = m.CateID, q = m.Quantity ?? 0, s = date < m.DateEnd, t = m.Type ?? 0 }) }; var obj = query.FirstOrDefault() ?? new SWItem { d = ConvertDate.TotalSeconds(DateTime.Today.AddDays(1)) }; obj.LstTimes = TypeTime.Hours(obj.d, date); return(obj); }
public async Task <ActionResult> AjaxForm() { var model = new OrderCarModel() { OrderCar = new OrderCarItem() { DepartureDate = ConvertDate.TotalSeconds(DateTime.Now.AddDays(1).Date), ReceiveDate = ConvertDate.TotalSeconds(DateTime.Now.AddDays(1).Date), ReturnDate = ConvertDate.TotalSeconds(DateTime.Now.AddDays(1).Date) } }; if (DoAction == ActionType.Edit) { model.OrderCar = await _orderCarApi.GetById(ArrId.FirstOrDefault()); } model.Supplier = _apiSupplieAPI.GetItemById(model.OrderCar.SupplierId); model.Category = _categoryApi.GetItemById(model.OrderCar.CarId); model.OrderCar.Quantity = model.OrderCar.Quantity; model.OrderCar.UnitName = model.Category.UnitName; model.Workshops = await _workshopApi.GetAll(); model.Cars = await _carApi.GetListAssign(model.Category.UnitID.Value); ViewBag.Action = DoAction; return(View("AddForm", model)); }
public ActionResult ActiveFrei(string key, Guid userId, string lstArrId) { try { if (key != Keyapi) { return(Json(0, JsonRequestBehavior.AllowGet)); } var lstInt = FDIUtils.StringToListInt(lstArrId); var model = _da.GetListArrId(lstInt); foreach (var item in model.Where(c => c.IsDelete == false)) { item.IsActive = true; item.DateActive = ConvertDate.TotalSeconds(DateTime.Now); item.Status = (int)StatusWarehouse.Waitting; item.UserActive = userId; } _da.Save(); return(Json(1, JsonRequestBehavior.AllowGet)); } catch (Exception) { return(Json(0, JsonRequestBehavior.AllowGet)); } }
public ActionResult Add(OrderCarItem request) { _da.Add(new OrderCar() { SupplierId = request.SupplierId, Quantity = request.Quantity, CarId = request.CarId, Code = request.Code, DateCreate = ConvertDate.TotalSeconds(DateTime.Now), DepartureDate = request.DepartureDate, ReceiveDate = request.ReceiveDate, ReturnDate = request.ReturnDate, ProductId = request.ProductId, Price = request.Price, PriceNow = request.PriceNow, IsDelete = false, Status = (int)OrderCarStatus.News, UserCreateId = Userid.Value, TodayCode = request.TodayCode.Value, WorkshopID = request.WorkshopID }); _da.Save(); return(Json(new JsonMessage() { Erros = false }, JsonRequestBehavior.AllowGet)); }
public ActionResult AddEvaluate(string key, int status, string itemId, string lstRet) { var now = ConvertDate.TotalSeconds(DateTime.Now); var lstInt = FDIUtils.StringToListInt(itemId); try { if (key != Keyapi) { return(Json(0, JsonRequestBehavior.AllowGet)); } var lstProductCode = _da.GetListProductCode(lstInt); var lst = JsonConvert.DeserializeObject <List <ProductCode_CostUser> >(lstRet); foreach (var item in lst) { item.UserCreated = UserId(); item.DateCreated = now; } var json = new JavaScriptSerializer().Serialize(lst); foreach (var item in lstProductCode) { item.ProductCode_CostUser = JsonConvert.DeserializeObject <List <ProductCode_CostUser> >(json); item.Status = status; } _da.Save(); return(Json(1, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(0, JsonRequestBehavior.AllowGet)); } }
public async Task <ActionResult> AddForm(int supplierId, int categoryId, decimal quantity, int todayCode) { var model = new OrderCarModel { OrderCar = new OrderCarItem() { DepartureDate = ConvertDate.TotalSeconds(DateTime.Now.AddDays(1).Date), ReceiveDate = ConvertDate.TotalSeconds(DateTime.Now.AddDays(1).Date), ReturnDate = ConvertDate.TotalSeconds(DateTime.Now.AddDays(1).Date) }, Supplier = _apiSupplieAPI.GetItemById(supplierId), Category = _categoryApi.GetItemById(categoryId), Workshops = await _workshopApi.GetAll(), }; model.OrderCar.Quantity = quantity; model.OrderCar.UnitName = model.Category.UnitName; model.Cars = await _carApi.GetListAssign(model.Category.UnitID.Value); var productitem = await _productToDayApi.GetItem(todayCode, categoryId, supplierId); model.OrderCar.Price = productitem.Price.Value; ViewBag.Action = DoAction; return(View(model)); }
public List <OrderAppSaleItem> GetListOrderAppSale(int rowPerPage, int page, int aid, string cus, string fromd, string tod, ref int total) { var datef = !string.IsNullOrEmpty(fromd) ? ConvertDate.TotalSeconds(ConvertUtil.ToDateTime(fromd)) : ConvertDate.TotalSeconds(new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1)); var datet = !string.IsNullOrEmpty(tod) ? ConvertDate.TotalSeconds(ConvertUtil.ToDateTime(tod).AddDays(1)) : ConvertDate.TotalSeconds(DateTime.Now.AddDays(1)); var query = from c in FDIDB.Shop_ContactOrder where c.AgencyId == aid && datef <= c.DateCreated && c.DateCreated <= datet && c.IsDelete != true orderby c.ID descending select new OrderAppSaleItem { ID = c.ID, P = c.Mobile, N = c.CustomerName, A = c.Address, CId = c.CustomerID, D = c.DateCreated, S = c.Status, Note = c.Content, Pay = c.Payments ?? 0, Tp = c.TotalPrice ?? 0, }; if (!string.IsNullOrEmpty(cus)) { query = query.Where(c => c.N.Contains(cus)); } return(query.Paging(page, rowPerPage, ref total).ToList()); }
public ActionResult Imported(string key, string codeLogin) { try { if (key != Keyapi) { return(Json(0, JsonRequestBehavior.AllowGet)); } var storage = _da.GetById(ItemId); storage.Status = (int)StatusWarehouse.Imported; storage.DateImport = ConvertDate.TotalSeconds(DateTime.Now); var lstInt = GetListImportedItem(codeLogin); var temp = _da.GetListArrIdImport(lstInt); foreach (var dnImportProduct in temp) { dnImportProduct.AgencyId = Agencyid(); } _da.Save(); return(Json(1, JsonRequestBehavior.AllowGet)); } catch (Exception) { return(Json(0, JsonRequestBehavior.AllowGet)); } }
public ActionResult Index(decimal?todayCode) { if (todayCode == null) { return(RedirectToAction("Index", new { todayCode = ConvertDate.TotalSeconds(DateTime.Now.AddDays(1).Date) })); } return(View(todayCode.Value)); }
public StorageWarehousing GetObjByID(int agencyId, int id) { var date = ConvertDate.TotalSeconds(DateTime.Now.AddHours(12)); var query = from o in FDIDB.StorageWarehousings where o.AgencyId == agencyId && (!o.IsDelete.HasValue || !o.IsDelete.Value) && o.ID == id && o.DN_RequestWare.Any(m => date < m.DateEnd) select o; return(query.FirstOrDefault()); }
public void TestMethod7() { var arr = File.ReadAllBytes("b.png"); var d = arr.Select(m => (int)m).ToList(); var b = JsonConvert.SerializeObject(d); var a = ConvertDate.TotalSeconds(DateTime.Now.Date.AddDays(1)); //var lst = _orderDA.GetListByCustomer(2, 1,1, out var i); }
public ActionResult UpdateActive(string key, string codeLogin, Guid userIdActive) { try { if (key != Keyapi) { return(Json(0, JsonRequestBehavior.AllowGet)); } var model = _da.GetById(ItemId); if (model == null) { return(Json(1, JsonRequestBehavior.AllowGet)); } UpdateModel(model); model.Status = (int)StatusWarehouse.Complete; model.IsActive = true; model.DateActive = ConvertDate.TotalSeconds(DateTime.Now); //model.Status = (int)StatusWarehouse.Waitting; model.UserActive = userIdActive; model.keyreq = Guid.NewGuid(); var dateCreated = Request["DateCreated_"]; var date = ConvertUtil.ToDateTime(dateCreated); var lst = model.FreightWareHouse_Active.Where(c => c.IsDelete == false).ToList(); var lstNew = GetListImportItemActive(codeLogin, date); //xóa var result1 = lst.Where(p => lstNew.All(p2 => p2.ImportProductGID != p.ImportProductGID)).ToList(); foreach (var i in result1) { i.IsDelete = true; } //sửa //foreach (var i in lst) //{ // var j = lstNew.FirstOrDefault(c => c.ProductID == i.ProductID); // if (j == null) continue; // i.Price = j.Price; // i.Quantity = j.Quantity; // i.TotalPrice = j.TotalPrice; // i.Date = j.Date; //} //thêm mới var result2 = lstNew.Where(p => lst.All(p2 => p2.ImportProductGID != p.ImportProductGID)).ToList(); model.FreightWareHouse_Active.AddRange(result2); //model.DateImport = date.TotalSeconds(); model.Note = HttpUtility.UrlDecode(model.Note); _da.Save(); return(Json(1, JsonRequestBehavior.AllowGet)); } catch (Exception) { return(Json(0, JsonRequestBehavior.AllowGet)); } }
public DN_Weekly_Schedule UpdateMapping(int weeklyId, int scheduleId, int agencyId) { var weeklySchedule = new DN_Weekly_Schedule { WeeklyID = weeklyId, ScheduleID = scheduleId, AgencyID = agencyId, DateCreated = ConvertDate.TotalSeconds(DateTime.Now) }; return(weeklySchedule); }
public ActionResult Update(string key, string codeLogin) { try { if (key != Keyapi) { return(Json(0, JsonRequestBehavior.AllowGet)); } var model = _da.GetById(ItemId); if (model == null) { return(Json(1, JsonRequestBehavior.AllowGet)); } UpdateModel(model); model.IsActive = false; model.Status = (int)StatusWarehouse.Pending; var dateCreated = Request["DateCreated_"]; var date = ConvertDate.StringToDate(dateCreated); var lst = model.FreightWarehouses.Where(c => c.IsDelete == false).ToList(); var lstNew = GetListImportItem(codeLogin, date); //xóa var result1 = lst.Where(p => lstNew.All(p2 => p2.ProductID != p.ProductID)).ToList(); foreach (var i in result1) { i.IsDelete = true; } //sửa foreach (var i in lst) { var j = lstNew.FirstOrDefault(c => c.ProductID == i.ProductID); if (j == null) { continue; } i.Quantity = j.Quantity; i.Price = j.Price; i.Date = j.Date; } //thêm mới var result2 = lstNew.Where(p => lst.All(p2 => p2.ProductID != p.ProductID)).ToList(); model.FreightWarehouses.AddRange(result2); model.DateImport = ConvertDate.TotalSeconds(date); model.Note = HttpUtility.UrlDecode(model.Note); _da.Save(); return(Json(1, JsonRequestBehavior.AllowGet)); } catch (Exception) { return(Json(0, JsonRequestBehavior.AllowGet)); } }
public ActionResult Update(string key, string codeLogin) { try { if (key != Keyapi) { return(Json(0, JsonRequestBehavior.AllowGet)); } var model = _da.GetById(ItemId); if (model == null) { return(Json(1, JsonRequestBehavior.AllowGet)); } UpdateModel(model); var dateCreated = Request["DateCreated_"]; var date = dateCreated.StringToDate(); var lst = model.DN_Import.Where(c => c.IsDelete == false).ToList(); var lstNew = GetListImportItem(codeLogin, date); //xóa var result1 = lst.Where(p => lstNew.All(p2 => p2.ValueId != p.ValueId)); foreach (var i in result1) { i.Shop_Product_Value.Quantity = i.Shop_Product_Value.Quantity - i.Quantity; i.IsDelete = true; } foreach (var i in lst) { var j = lstNew.FirstOrDefault(c => c.ValueId == i.ValueId); if (j == null) { continue; } i.Shop_Product_Value.Quantity = i.Shop_Product_Value.Quantity - i.Quantity + j.Quantity; i.Quantity = j.Quantity; i.Price = j.Price; i.DateEnd = j.DateEnd; } //thêm mới var result2 = lstNew.Where(p => lst.All(p2 => p2.ValueId != p.ValueId)).ToList(); model.DN_Import.AddRange(result2); model.DateImport = ConvertDate.TotalSeconds(date); model.Note = HttpUtility.UrlDecode(model.Note); _da.Save(); return(Json(1, JsonRequestBehavior.AllowGet)); } catch (Exception) { return(Json(0, JsonRequestBehavior.AllowGet)); } }
public List <DNCalendarItem> GetListSimpleByRequest(HttpRequestBase httpRequest, int agencyid, Guid?userid) { var date = ConvertDate.TotalSeconds(DateTime.Now); Request = new ParramRequest(httpRequest); var query = from o in FDIDB.DN_Calendar where o.IsDelete == false && o.DateEnd > date && o.AgencyID == agencyid && o.DN_Users.Any(m => m.UserId == userid) orderby o.Sort descending select new DNCalendarItem { ID = o.ID, Name = o.Name.Trim(), DateStart = o.DateStart, DateEnd = o.DateEnd, IsShow = o.IsShow, WeeklyScheduleItems = (from c in FDIDB.DN_Weekly_Schedule where c.AgencyID == agencyid && c.DN_Calendar_Weekly_Schedule.Any(m => m.CalenderID == o.ID) orderby c.WeeklyID, c.DN_Schedule.Sort select new WeeklyScheduleItem { WeeklyID = c.WeeklyID, ScheduleName = c.DN_Schedule.Name, }) }; if (!query.Any()) { query = from o in FDIDB.DN_Calendar where o.IsDelete == false && o.AgencyID == agencyid && o.DN_Roles.Any(m => m.DN_UsersInRoles.Any(n => n.UserId == userid && n.IsDelete == false)) orderby o.Sort descending select new DNCalendarItem { ID = o.ID, Name = o.Name.Trim(), DateStart = o.DateStart, DateEnd = o.DateEnd, IsShow = o.IsShow, WeeklyScheduleItems = (from c in FDIDB.DN_Weekly_Schedule where c.AgencyID == agencyid && c.DN_Calendar_Weekly_Schedule.Any(m => m.CalenderID == o.ID) orderby c.WeeklyID, c.DN_Schedule.Sort select new WeeklyScheduleItem { WeeklyID = c.WeeklyID, ScheduleName = c.DN_Schedule.Name, }) }; } query = query.SelectByRequest(Request, ref TotalRecord); return(query.ToList()); }
public ActionResult Add(string key, string code) { var msg = new JsonMessage(false, "Thêm mới dữ liệu thành công."); var model = new BiasProduce(); var lst = new List <ProductCode>(); var now = ConvertDate.TotalSeconds(DateTime.Now); try { if (key != Keyapi) { return(Json(0, JsonRequestBehavior.AllowGet)); } UpdateModel(model); var itemId = Request["ItemID"]; var start = Request["StartDate_"]; var end = Request["EndDate_"]; var startDate = start.StringToDecimal(); var endDate = end.StringToDecimal(); model.StartDate = startDate; model.EndDate = endDate; model.Name = HttpUtility.UrlDecode(model.Name); for (var i = 0; i <= model.Quantity; i++) { var item = new ProductCode { Code = "ssc-" + itemId + "-" + model.ProductID + "-" + i, Status = 0, DateCreated = now, StartDate = startDate, EndDate = endDate }; lst.Add(item); } model.ProductCodes = lst; var lstcpu = GetListItem(code, model.ProductID); model.Cost_Product_User = lstcpu; model.IsDeleted = false; _da.Add(model); _da.Save(); } catch (Exception ex) { msg.Erros = true; msg.Message = "Dữ liệu chưa được thêm mới."; Log2File.LogExceptionToFile(ex); } return(Json(msg, JsonRequestBehavior.AllowGet)); }
public ActionResult SendMail() { var msg = new JsonMessage(); var mailSscItem = new DNMailSSCItem(); try { var date = ConvertDate.TotalSeconds(DateTime.Now); UpdateModel(mailSscItem); mailSscItem.UserSendId = UserId; if (mailSscItem.Type == 1) { mailSscItem.IsDraft = false; } else if (mailSscItem.Type == 3) { mailSscItem.IsDraft = true; } mailSscItem.Status = 0; mailSscItem.IsDelete = false; mailSscItem.IsSpam = false; mailSscItem.IsRecycleBin = false; mailSscItem.IsImportant = false; mailSscItem.ListUrlPicture = Request["lstImages"]; mailSscItem.Content = Request.Unvalidated.Form["ContentE"]; mailSscItem.CreateDate = date; mailSscItem.UpdateDate = date; _dnMailSscapi.SetCacheMail(UserItem.AgencyID, mailSscItem); _dnMailSscapi.Add(UserItem.AgencyID, CodeLogin()); msg = new JsonMessage { Erros = false, ID = mailSscItem.ID.ToString(), Message = mailSscItem.Type == 1 ? "Thư của bạn đã được gửi đi" : "Thư của bạn đã được lưu vào hộp thư nháp" }; } catch (Exception ex) { LogHelper.Instance.LogError(GetType(), ex); } if (string.IsNullOrEmpty(msg.Message)) { msg.Message = "Không có hành động nào được thực hiện."; msg.Erros = true; } return(Json(msg, JsonRequestBehavior.AllowGet)); }
public AgencyItem GetbyID(int id) { var date = ConvertDate.TotalSeconds(DateTime.Now); var query = from c in FDIDB.DN_Agency where c.ID == id //&& c.MarketID.HasValue && c.MarketID > 0 select new AgencyItem { MarketID = c.MarketID, AreaID = c.Market.AreaID, TotalDeposit = c.WalletValue }; return(query.FirstOrDefault()); }
public DNTimeJobItem JobTimeCheckOut(Guid userId, DNTimeJobItem objItem) { var date = DateTime.Now; var totalS = date.Hour * 3600 + date.Minute * 60; var list = GetWeeklyScheduleday(userId, DateTime.Today).OrderByDescending(m => m.ScheduleTimeStart); var obj = list.FirstOrDefault(m => (m.ScheduleTimeStart >= totalS && m.ScheduleTimeEnd > totalS) || m.ScheduleTimeEnd <= totalS); objItem.DateEnd = ConvertDate.TotalSeconds(date); if (obj != null) { objItem.ScheduleEndID = obj.ScheduleID; objItem.MinutesEarly = (int)(obj.ScheduleTimeEnd - totalS) / 60; } objItem.UserId = userId; return(objItem); }
public DNTimeJobItem JobTimeCheckIn(Guid userId, DNTimeJobItem objItem) { var date = DateTime.Now; var totalS = date.Hour * 3600 + date.Minute * 60; var list = GetWeeklyScheduleday(userId, DateTime.Today); var obj = list.FirstOrDefault(m => m.ScheduleTimeStart >= totalS || (m.ScheduleTimeStart <totalS && m.ScheduleTimeEnd> totalS)); objItem.DateCreated = ConvertDate.TotalSeconds(date); if (obj != null) { objItem.ScheduleID = obj.ScheduleID; objItem.MinutesLater = (int)(obj.ScheduleTimeStart - totalS) / 60; } objItem.UserId = userId; return(objItem); }
public ActionResult ProcessComment() { var msg = new JsonMessage(); var newsCommentItem = new DNNewsCommentItem(); var id = Convert.ToInt32(Request["ParentId"]); try { if (id > 1) { newsCommentItem.ParentId = id; newsCommentItem.IsLevel = 2; } else { newsCommentItem.IsLevel = 1; newsCommentItem.ParentId = 1; } newsCommentItem.NewsSSCID = Convert.ToInt32(Request["NewsSSCID"]); newsCommentItem.Message = Request.Unvalidated["Message"]; newsCommentItem.DateCreated = ConvertDate.TotalSeconds(DateTime.Now); newsCommentItem.IsShow = true; newsCommentItem.UserId = UserId; var json = new JavaScriptSerializer().Serialize(newsCommentItem); _newsCommentApi.Add(UserItem.AgencyID, json); msg = new JsonMessage { Erros = false, ID = newsCommentItem.ID.ToString(), Message = "Bạn bình luận thành công !" }; } catch (Exception ex) { LogHelper.Instance.LogError(GetType(), ex); } if (string.IsNullOrEmpty(msg.Message)) { msg.Message = "Không có hành động nào được thực hiện."; msg.Erros = true; } return(Json(msg, JsonRequestBehavior.AllowGet)); }
public ActionResult Add(string key, string json) { var model = new Base.Customer(); var msg = new JsonMessage(false, "Thêm mới dữ liệu thành công."); try { UpdateModel(model); var birth = Request["Birthday_"]; var parent = Request["Parent"]; var serial = Request["CardSerial"]; var pin = Request["PinCard"]; var NoteCate = Request["NoteCate"]; if (!string.IsNullOrEmpty(serial)) { var carditem = _da.GetCardItem(serial, pin); model.CardID = carditem.ID; } model.FullName = HttpUtility.UrlDecode(model.FullName); model.Address = HttpUtility.UrlDecode(model.Address); model.Birthday = birth.StringToDecimal(); model.DateCreated = ConvertDate.TotalSeconds(DateTime.Now); model.IsDelete = false; model.IsActive = true; model.PasswordSalt = FDIUtils.CreateSaltKey(5); model.PassWord = FDIUtils.CreatePasswordHash(model.PassWord ?? "fdi123456", model.PasswordSalt); if (!string.IsNullOrEmpty(NoteCate)) { var customerCare = new Customer_Care { Note = HttpUtility.UrlDecode(NoteCate), AgencyId = Agencyid() }; model.Customer_Care.Add(customerCare); } _da.Add(model); _da.Save(); } catch (Exception ex) { msg.Erros = true; msg.Message = "Dữ liệu chưa được thêm mới"; Log2File.LogExceptionToFile(ex); } return(Json(msg, JsonRequestBehavior.AllowGet)); }
public ActionResult Update(string key, int agencyId, string json) { var msg = new JsonMessage(false, "Cập nhật dữ liệu thành công."); try { if (key == Keyapi) { var role = JsonConvert.DeserializeObject <DNRolesJsonItem>(json); var obj = _dl.GetById(role.RoleId); if (role.RoleName.Trim().ToLower() != "admin" && obj.RoleName.ToLower() == "admin") { msg.Erros = true; msg.Message = "Bạn không được phép chình sửa tên quyền Admin trong hệ thống."; return(Json(msg, JsonRequestBehavior.AllowGet)); } obj = UpdateRole(obj, role); var lst = obj.DN_UsersInRoles.Where(c => c.IsDelete == false); var lsGuiId = GetListUser(role.Code); var result1 = lst.Where(p => lsGuiId.All(p2 => p2.UserId != p.UserId)); foreach (var i in result1) { i.IsDelete = true; } var result2 = lsGuiId.Where(p => lst.All(p2 => p2.UserId != p.UserId)).ToList(); var listAdd = result2.Select(guid => new DN_UsersInRoles { RoleId = obj.RoleId, UserId = guid.UserId, AgencyID = agencyId, IsDelete = false, DateCreated = ConvertDate.TotalSeconds(DateTime.Now) }).ToList(); obj.DN_UsersInRoles.AddRange(listAdd); _dl.Save(); } } catch (Exception ex) { msg.Erros = true; msg.Message = "Dữ liệu chưa được cập nhật"; Log2File.LogExceptionToFile(ex); } return(Json(msg, JsonRequestBehavior.AllowGet)); }
public List <SWItem> ListStorageByUser(int rowPerPage, int page, int agencyId, int status, ref int total) { var date = ConvertDate.TotalSeconds(DateTime.Now.AddHours(12)); var query = from o in FDIDB.StorageWarehousings where o.AgencyId == agencyId && (!o.IsDelete.HasValue || !o.IsDelete.Value) && o.Status == status orderby o.ID descending select new SWItem { id = o.ID, n = o.Name, c = o.Code, d = o.DateRecive ?? 0, s = o.DN_RequestWare.Any(m => m.DateEnd > date) }; return(query.Paging(page, rowPerPage, ref total).ToList()); }
public ActionResult Actions() { var msg = new JsonMessage(); var model = new Send_Card(); switch (DoAction) { case ActionType.Add: try { var customerid = Request["CustomerID"]; var lstSerial = Request["LstSerial"]; var lstInt = FDIUtils.StringToListInt(lstSerial); foreach (var i in lstInt) { _da.Add(new Send_Card { CustomerID = int.Parse(customerid), //CardID = i, DateCreate = ConvertDate.TotalSeconds(DateTime.Now) }); } _da.Save(); msg = new JsonMessage { Erros = false, ID = model.ID.ToString(), Message = "Đã cập nhật thành công" }; } catch (Exception ex) { } break; } if (string.IsNullOrEmpty(msg.Message)) { msg.Message = "Không có hành động nào được thực hiện."; msg.Erros = true; } return(Json(msg, JsonRequestBehavior.AllowGet)); }
public ActionResult Add(string key, int agencyId, string json) { var msg = new JsonMessage(false, "Thêm mới dữ liệu thành công."); try { if (key == Keyapi) { var obj = new DN_Roles(); var role = JsonConvert.DeserializeObject <DNRolesJsonItem>(json); if (role.RoleName.Trim().ToLower() == "admin") { msg.Erros = true; msg.Message = "Quyền Admin đã tồn tại trong hệ thống."; return(Json(msg, JsonRequestBehavior.AllowGet)); } obj = UpdateRole(obj, role); var lsGuiId = GetListUser(role.Code); obj.AgencyID = agencyId; var list = lsGuiId.Select(guid => new DN_UsersInRoles { RoleId = obj.RoleId, UserId = guid.UserId, AgencyID = agencyId, IsDelete = false, DateCreated = ConvertDate.TotalSeconds(DateTime.Now) }).ToList(); obj.DN_UsersInRoles = list; obj.RoleId = role.RoleId; _dl.Add(obj); _dl.Save(); } } catch (Exception ex) { msg.Erros = true; msg.Message = "Dữ liệu chưa được thêm mới"; Log2File.LogExceptionToFile(ex); } return(Json(msg, JsonRequestBehavior.AllowGet)); }
public ActionResult AddCard(string key, int id, string card, string code) { var json = new JsonMessage { Erros = true, Message = "Không có hành động nào thực hiện" }; try { var model = _cardDa.GetCardItem(card, code); if (model != null) { if (!_cardDa.CheckSendCard(model.ID)) { _cardDa.Add(new Send_Card { CustomerID = id, CardID = model.ID, DateCreate = ConvertDate.TotalSeconds(DateTime.Now) }); _cardDa.Save(); json.Erros = false; json.Message = "Thêm thẻ thành công"; } else { json.Erros = true; json.Message = "Thẻ đã được sử dụng"; } } else { json.Erros = true; json.Message = "Thẻ không tồn tại"; } return(Json(json, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(json, JsonRequestBehavior.AllowGet)); } }