public ActionResult GetListByParentID(string key, int parentId, Guid UserId, string listRole) { var lst = FDIUtils.StringToListInt(listRole); var obj = key != Keyapi ? new List <ModuleItem>() : _da.GetListByParentID(parentId, Agencyid(), UserId, lst); return(Json(obj, JsonRequestBehavior.AllowGet)); }
public JsonResult Register() { var msg = new JsonMessage { Erros = false, Message = "Đăng ký thành công", }; try { var cus = new Customer(); var da = new CustomerDA(); UpdateModel(cus); cus.DateCreated = DateTime.Now.TotalSeconds(); cus.IsDelete = false; cus.PasswordSalt = FDIUtils.RandomKey(8); cus.PassWord = FDIUtils.Encrypt(cus.PassWord, cus.PasswordSalt); da.Add(cus); da.Save(); } catch (Exception) { msg.Erros = true; msg.Message = "Vui lòng thử lại!"; } return(Json(msg)); }
public ActionResult UpdatePass(string key, string code, string passold, string passnew) { var msg = new JsonMessage(false, "Thay đổi mật khẩu thành công."); try { if (key == Keyapi) { var userlogin = _dalogin.GetUserItemByCode(code); if (userlogin != null) { var user = _da.GetById(userlogin.UserId); if (user != null && FDIUtils.CreatePasswordHash(passold, user.PasswordSalt) == user.Password) { user.Password = FDIUtils.CreatePasswordHash(passnew, user.PasswordSalt); _da.Save(); } } } } catch (Exception ex) { msg.Erros = true; msg.Message = "Mật khẩu chưa được thay đôi."; Log2File.LogExceptionToFile(ex); } return(Json(msg, JsonRequestBehavior.AllowGet)); }
public List <Discount> GetListByArrId(string ltsArrID) { var arrId = FDIUtils.StringToListInt(ltsArrID); var query = from c in FDIDB.Discounts where arrId.Contains(c.ID) select c; return(query.ToList()); }
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 List <System_Color> GetListByArrID(string ltsArrID) { var ltsArrId = FDIUtils.StringToListInt(ltsArrID); var query = from c in FDIDB.System_Color where ltsArrId.Contains(c.ID) && !c.Shop_Product.Any() select c; return(query.ToList()); }
public ActionResult Delete(string key, string lstArrId) { var msg = new JsonMessage(false, "Xóa dữ liệu thành công."); try { if (key == Keyapi) { var lstInt = FDIUtils.StringToListInt(lstArrId); var lst = _da.GetListArrId(lstInt); foreach (var item in lst) { item.IsDeleted = true; foreach (var i in item.Export_Product_Value) { i.DN_Import.QuantityOut = i.DN_Import.QuantityOut - i.Quantity; } } _da.Save(); } } catch (Exception ex) { msg.Erros = true; msg.Message = "Dữ liệu chưa được xóa."; Log2File.LogExceptionToFile(ex); } return(Json(msg, JsonRequestBehavior.AllowGet)); }
public ActionResult Active(string key, string lstArrId) { var msg = new JsonMessage(false, "Duyệt dữ liệu thành công !"); try { if (key != Keyapi) { return(Json(0, JsonRequestBehavior.AllowGet)); } var lstInt = FDIUtils.StringToListInt(lstArrId); var lst = _da.GetListArrId(lstInt); foreach (var item in lst.Where(c => c.IsDelete == false)) { item.IsActive = true; item.DateActive = DateTime.Now.TotalSeconds(); } _da.Save(); } catch (Exception ex) { msg.Erros = true; msg.Message = "Phiếu chưa được duyệt."; } return(Json(msg, JsonRequestBehavior.AllowGet)); }
public ActionResult AddCalendarWeeklySchedule(string key, int calenderId, string weeklySchedule) { if (key == Keyapi) { var obj = _da.GetByCalendarWeeklyScheduleItemId(calenderId); var lstweeklySchedule = FDIUtils.StringToListInt(weeklySchedule); foreach (var weeklyScheduleId in lstweeklySchedule.Where(m => obj.DNCalendarWeeklySchedule.All(c => c.MWSID != m))) { var item = CalendarWeeklySchedule(weeklyScheduleId, calenderId, Agencyid()); _calendarWeeklyScheduleBl.Add(item); } var listint = obj.DNCalendarWeeklySchedule.Where(m => lstweeklySchedule.All(c => c != m.MWSID)).Select(n => n.ID).ToList(); if (listint.Any()) { var list = _calendarWeeklyScheduleBl.GetListByArrId(listint); foreach (var weeklyScheduleId in list) { _calendarWeeklyScheduleBl.Delete(weeklyScheduleId); } } _calendarWeeklyScheduleBl.Save(); return(Json(1, JsonRequestBehavior.AllowGet)); } return(Json(0, 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 ActionResult Update(string key) { try { if (key != Keyapi) { return(Json(0, JsonRequestBehavior.AllowGet)); } var model = _da.GetById(ItemId); UpdateModel(model); var pictureId = Convert.ToInt32(Request["Value_DefaultImages"]); if (pictureId > 0) { model.PictureID = pictureId; } var dateStart = Request["DateStart_"]; var dateEnd = Request["DateEnd_"]; var lstRet = Request["lstRet"]; model.Name = HttpUtility.UrlDecode(model.Name); model.DateStart = dateStart.StringToDecimal(); model.DateEnd = dateEnd.StringToDecimal(); model.Shop_Product.Clear(); var lstInt = FDIUtils.StringToListInt(lstRet); model.Shop_Product = _da.GetListProduct(lstInt); _da.Save(); return(Json(1, JsonRequestBehavior.AllowGet)); } catch (Exception) { return(Json(0, JsonRequestBehavior.AllowGet)); } }
protected string SetCodeC() { var date = DateTime.Now; var code = FDIUtils.RandomCode(5); var expires = date.AddHours(3); var codeCookie = HttpContext.Request.Cookies["CodeC"]; if (codeCookie == null) { codeCookie = new HttpCookie("CodeC") { Value = code, Expires = expires }; Response.Cookies.Add(codeCookie); } else { if (string.IsNullOrEmpty(codeCookie.Value)) { codeCookie.Value = code; codeCookie.Expires = expires; Response.Cookies.Add(codeCookie); } } return(code); }
public ActionResult Active(string key, Guid userId, string lstArrId) { var msg = new JsonMessage { Erros = false, Message = "Duyệt đơn đặt hàng thành công." }; 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.Status = (int)StatusWarehouse.Waitting; } _da.Save(); return(Json(msg, JsonRequestBehavior.AllowGet)); } catch (Exception) { msg = new JsonMessage { Erros = true, Message = "Có lỗi xảy ra." }; return(Json(msg, JsonRequestBehavior.AllowGet)); } }
public ActionResult UpdateCusPass(string key, string code, string passold, string passnew) { try { if (key == Keyapi) { var userlogin = _dalogin.GetCustomerByCode(code); if (userlogin != null) { var user = _customerDa.GetById(userlogin.ID); if (user != null && FDIUtils.CreatePasswordHash(passold, user.PasswordSalt) == user.PassWord) { user.PassWord = FDIUtils.CreatePasswordHash(passnew, user.PasswordSalt); _customerDa.Save(); } else { return(Json(2, JsonRequestBehavior.AllowGet)); } } } } catch (Exception ex) { return(Json(0, JsonRequestBehavior.AllowGet)); } return(Json(1, JsonRequestBehavior.AllowGet)); }
public List <DN_Schedule> GetScheduleArrId(string lst) { var ltsArrId = FDIUtils.StringToListInt(lst); var query = from c in FDIDB.DN_Schedule where ltsArrId.Contains(c.ID) select c; return(query.ToList()); }
public ActionResult Update(string key, string code, string json) { var msg = new JsonMessage(false, "Cập nhật dữ liệu thành công."); try { if (key == Keyapi) { var user = JsonConvert.DeserializeObject <DNUserAddItem>(json); var obj = _da.GetById(user.UserId); if (!string.IsNullOrEmpty(user.PasswordSalt) && user.PasswordSalt.Length > 5) { obj.Password = FDIUtils.CreatePasswordHash(user.PasswordSalt, obj.PasswordSalt); } UpdateBase(obj, user); _da.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)); }
/// <summary> /// Lấy về danh sách qua mảng id /// </summary> /// <param name="ltsArrId">Mảng ID</param> /// <returns>Danh sách bản ghi</returns> public List <Category> GetListByArrId(string lstId) { var ltsArrId = FDIUtils.StringToListInt(lstId); var query = from c in FDIDB.Categories where ltsArrId.Contains(c.Id) select c; return(query.ToList()); }
public ActionResult AddUser(string key, string code, string json) { var msg = new JsonMessage(false, "Thêm mới dữ liệu thành công."); try { if (key == Keyapi) { var user = JsonConvert.DeserializeObject <DNUserAddItem>(json); var saltKey = FDIUtils.CreateSaltKey(5); var sha1PasswordHash = FDIUtils.CreatePasswordHash(user.PasswordSalt, saltKey); var obj = new DN_Users { UserId = Guid.NewGuid(), PasswordSalt = saltKey, Password = sha1PasswordHash, AgencyID = Agencyid(), CreateDate = ConvertDate.TotalSeconds(DateTime.Now), IsDeleted = false }; UpdateBase(obj, user); _da.Add(obj); _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 Add(string key) { var msg = new JsonMessage(false, "Thêm mới dữ liệu thành công."); var model = new Shop_Product(); try { if (key != Keyapi) { return(Json(0, JsonRequestBehavior.AllowGet)); } UpdateModel(model); model.IsDelete = false; model.IsShow = false; model.DateCreated = DateTime.Now; model.NameAscii = FDIUtils.Slug(model.Name); model.Quantity = 0; model.QuantityOut = 0; _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 Delete(string key, string lstArrId) { var msg = new JsonMessage(false, "Xóa dữ liệu thành công."); try { if (key == Keyapi) { var lstInt = FDIUtils.StringToListInt(lstArrId); var lst = _da.GetListArrId(lstInt); foreach (var item in lst) { //item.UserInRoleID = null; item.IsDelete = true; } _da.Save(); } } catch (Exception ex) { msg.Erros = true; msg.Message = "Dữ liệu chưa được xóa"; Log2File.LogExceptionToFile(ex); } return(Json(msg, JsonRequestBehavior.AllowGet)); }
public ActionResult ActionsAdd(string codep, int pi) { var code = FDIUtils.RandomCode(8); var obj = Add(code, codep, pi); return(Json(obj, JsonRequestBehavior.AllowGet)); }
public ActionResult Hide(string key, string lstArrId) { var msg = new JsonMessage { Erros = true, Message = "Không có hành động nào được thực hiện." }; if (key == Keyapi) { var lstInt = FDIUtils.StringToListInt(lstArrId); var list = _da.GetListByArrId(lstInt); var stbMessage = new StringBuilder(); foreach (var item in list) { item.IsShow = false; stbMessage.AppendFormat("Đã ẩn <b>{0}</b>.<br />", Server.HtmlEncode(item.Name)); } _da.Save(); msg.Erros = false; msg.ID = lstArrId; msg.Message = stbMessage.ToString(); return(Json(msg, JsonRequestBehavior.AllowGet)); } return(Json(msg, JsonRequestBehavior.AllowGet)); }
public ActionResult GetlistByTagUserId(string key, string keyword, Guid guid, int agencyId, string listRole, int parentId, int moduleId) { //var user = _dllogin.GetUserItemByCode(code); var lst = FDIUtils.StringToListInt(listRole); var obj = key != Keyapi ? new List <ActionActiveItem>() : _da.GetlistByTagUserId(keyword, guid, lst, agencyId, parentId, moduleId); return(Json(obj, JsonRequestBehavior.AllowGet)); }
public RedirectToRouteResult ResetPassword(Guid id) { var user = _userService.Get(id); var pass = FDIUtils.RandomString(6).ToLower(); _passwordService.ChangePassword(user, pass); return(RedirectToAction("Password", new { id })); }
public ActionResult Update(string key, string json) { var msg = new JsonMessage(false, "Cập nhật dữ liệu thành công."); try { if (key != Keyapi) { return(Json(0, JsonRequestBehavior.AllowGet)); } var model = _da.GetById(ItemId); var birth = Request["Birthday_"]; var serial = Request["CardSerial"]; var pin = Request["PinCard"]; var NoteCate = Request["NoteCate"]; var PassWord = Request["PassWord"]; model.Birthday = birth.StringToDecimal(); var phone = model.Phone; UpdateModel(model); if (!model.CardID.HasValue && !string.IsNullOrEmpty(serial)) { var carditem = _da.GetCardItem(serial, pin); if (carditem != null) { model.CardID = carditem.ID; } } var customerCare = model.Customer_Care.FirstOrDefault(); if (customerCare != null && !string.IsNullOrEmpty(NoteCate)) { customerCare.Note = HttpUtility.UrlDecode(NoteCate); } else if (!string.IsNullOrEmpty(NoteCate)) { customerCare = new Customer_Care { Note = HttpUtility.UrlDecode(NoteCate), AgencyId = Agencyid() }; model.Customer_Care.Add(customerCare); } if (!string.IsNullOrEmpty(PassWord)) { model.PassWord = FDIUtils.CreatePasswordHash(PassWord, model.PasswordSalt); } model.FullName = HttpUtility.UrlDecode(model.FullName); model.Address = HttpUtility.UrlDecode(model.Address); model.Phone = phone; _da.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 <DN_File_Mail> GetFileMailArrId(string lstId) { var ltsArrId = FDIUtils.StringToListInt(lstId); var query = from o in FDIDB.DN_File_Mail where ltsArrId.Contains(o.ID) select o; return(query.ToList()); }
public List <Product_Size> ListByArrId(string lstId) { var ltsArrId = FDIUtils.StringToListInt(lstId); var query = from o in FDIDB.Product_Size where ltsArrId.Contains(o.ID) select o; return(query.ToList()); }
public List <DN_Weekly> GetWeeklyArrId(string lstId) { var ltsArrId = FDIUtils.StringToListInt(lstId); var query = from o in FDIDB.DN_Weekly where ltsArrId.Contains(o.ID) select o; return(query.ToList()); }
public List <Ward> GetByListArrId(string lstInt) { var lst = FDIUtils.StringToListInt(lstInt); var query = from c in FDIDB.Wards where lst.Contains(c.ID) select c; return(query.ToList()); }
public List <Order_Debt> GetListByArrId(string lstId) { var ltsArrId = FDIUtils.StringToListInt(lstId); var query = from o in FDIDB.Order_Debt where ltsArrId.Contains(o.ID) select o; return(query.ToList()); }