public JsonResult Delete(int id) { var msg = new JMessage() { Error = false, Title = "" }; try { var data = _context.CandiateBasic.FirstOrDefault(x => x.Id == id); if (data != null) { _context.CandiateBasic.Remove(data); _context.SaveChanges(); msg.Title = "Xóa ứng viên thành công!"; } else { msg.Error = true; msg.Title = "Ứng viên không tồn tại!"; } } catch (Exception ex) { msg.Error = true; msg.Title = "Có lỗi xảy ra khi xóa!"; } return(Json(msg)); }
public JsonResult Insert([FromBody] MaterialProductGroup obj) { var msg = new JMessage { Title = "", Error = false }; try { var exist = _context.MaterialProductGroups.FirstOrDefault(x => x.Code == obj.Code); if (exist != null) { msg.Error = true; msg.Title = "Mã nhóm vật tư đã tồn tại"; } else { obj.CreatedBy = ESEIM.AppContext.UserName; obj.CreatedTime = DateTime.Now; _context.MaterialProductGroups.Add(obj); _context.SaveChanges(); msg.Title = "Thêm nhóm vật tư thành công"; } } catch { msg.Error = true; msg.Title = "Thêm nhóm vật tư lỗi"; } return(Json(msg)); }
public JsonResult Insert([FromBody] UrencoMaterialProductGroup obj) { var msg = new JMessage { Title = "", Error = false }; try { var exist = _context.UrencoMaterialProductGroup.FirstOrDefault(x => x.Code == obj.Code); if (exist != null) { msg.Error = true; msg.Title = String.Format(CommonUtil.ResourceValue("MPG_MSG_MPG_CODE_ALREADY_EXIST"));//"Mã nhóm vật tư đã tồn tại"; } else { obj.CreatedBy = ESEIM.AppContext.UserName; obj.CreatedTime = DateTime.Now; _context.UrencoMaterialProductGroup.Add(obj); _context.SaveChanges(); msg.Title = String.Format(CommonUtil.ResourceValue("COM_MSG_ADD_SUCCESS"), CommonUtil.ResourceValue("MGP_LBL_MGP"));//"Thêm nhóm vật tư thành công"; } } catch { msg.Error = true; msg.Title = String.Format(CommonUtil.ResourceValue("MGP_MSG_ADD_ERROR")); //"Thêm nhóm vật tư lỗi"; } return(Json(msg)); }
public JsonResult Insert([FromBody] HolidayModel obj) { var msg = new JMessage() { Error = false, Title = "" }; try { var holiday = new HolidayDate { CalendarDay = DateTime.ParseExact(obj.CalendarDay, "dd/MM/yyyy", CultureInfo.InvariantCulture), LunarDay = DateTime.ParseExact(obj.LunarDay, "dd/MM/yyyy", CultureInfo.InvariantCulture), DayOfWeek = obj.DayOfWeek, Note = obj.Note, CreatedTime = DateTime.Now }; _context.HolidayDates.Add(holiday); _context.SaveChanges(); msg.Title = String.Format(CommonUtil.ResourceValue("COM_MSG_ADD_SUCCESS"), CommonUtil.ResourceValue("ADM_DAYOFF_TITLE_INFORMATION_DAYOFF")); } catch (Exception ex) { msg.Error = true; msg.Title = String.Format(CommonUtil.ResourceValue("COM_MSG_ADD_FAILED"), CommonUtil.ResourceValue("ADM_DAYOFF_TITLE_INFORMATION_DAYOFF")); } return(Json(msg)); }
public JsonResult Insert([FromBody] MaterialPaymentTicket obj) { var msg = new JMessage() { Error = false, Title = "" }; try { var query = _context.MaterialPaymentTickets.Where(x => x.PayCode.Equals(obj.PayCode)).FirstOrDefault(); if (query == null) { obj.CreatedTime = DateTime.Now; obj.CreatedBy = ESEIM.AppContext.UserName; _context.MaterialPaymentTickets.Add(obj); _context.SaveChanges(); msg.Title = "Thêm phiếu thu - chi thành công"; return(Json(msg)); } else { msg.Error = true; msg.Title = "Mã phiếu thu - chi đã tồn tại"; } return(Json(msg)); } catch (Exception ex) { msg.Error = true; msg.Title = "Thêm phiếu thu - chi lỗi!"; } return(Json(msg)); }
public JsonResult Insert([FromBody] UrencoAssetsCategory data) { var msg = new JMessage() { Error = false }; try { var checkExist = _context.UrencoAssetsCategorys.FirstOrDefault(x => x.CatCode.ToLower() == data.CatCode.ToLower() && !x.IsDeleted); if (checkExist != null) { msg.Error = true; msg.Title = String.Format(CommonUtil.ResourceValue("FCRE_MSG_CAT_CODE"));//"Đã tồn danh mục quỹ!"; } else { data.CreatedBy = ESEIM.AppContext.UserName; data.CreatedTime = DateTime.Now; if (string.IsNullOrEmpty(data.CatParent)) { data.CatParent = "CAT_FUND"; } _context.UrencoAssetsCategorys.Add(data); _context.SaveChanges(); msg.Title = String.Format(CommonUtil.ResourceValue("FCRE_MSG_ADD_DONE"));//"Thêm danh mục quỹ thành công"; } } catch (Exception ex) { msg.Error = true; msg.Title = String.Format(CommonUtil.ResourceValue("FCRE_MSG_ADD_ERROR"));//"Có lỗi xảy ra khi thêm?"; } return(Json(msg)); }
public object Insert([FromBody] MaterialType data) { var msg = new JMessage() { Error = false }; try { if (_context.MaterialTypes.FirstOrDefault(x => x.Code == data.Code) == null) { data.CreatedBy = ESEIM.AppContext.UserName; data.CreatedTime = DateTime.Now; _context.MaterialTypes.Add(data); _context.SaveChanges(); msg.Title = "Thêm thành công loại vật tư!"; } else { msg.Error = true; msg.Title = "Mã loại vật tư đã tồn tại!"; } } catch (Exception ex) { msg.Error = true; msg.Title = "Có lỗi xảy ra khi thêm loại vật tư!"; msg.Object = ex; } return(Json(msg)); }
public JsonResult Insert([FromBody] WeekWorkingScheduleModel obj) { var msg = new JMessage { Error = false, Title = "" }; try { var model = new DispatchesWeekWorkingScheduler { Chair = obj.Chair, CreatedTime = !string.IsNullOrEmpty(obj.CreatedTime) ? DateTime.ParseExact(obj.CreatedTime, "dd/MM/yyyy", CultureInfo.InvariantCulture) : DateTime.Now, TimeStart = obj.TimeStart, TimeEnd = obj.TimeEnd, Room = obj.Room, Composition = obj.Composition, Content = obj.Content, CreatedBy = ESEIM.AppContext.UserId, }; _context.DispatchesWeekWorkingSchedulerss.Add(model); _context.SaveChanges(); msg.Title = "Thêm sự kiện thành công !"; } catch (Exception ex) { msg.Title = "Có lỗi khi thêm sự kiện!"; msg.Error = true; } return(Json(msg)); }
public JsonResult insert([FromBody] Location obj) { var msg = new JMessage() { Error = false }; try { Location obj1 = new Location(); obj1.code = obj.code; obj1.name = obj.name; obj1.parent_id = obj.parent_id; // obj1.Birthday = Convert.ToDateTime(obj.Birthday); obj1.description = obj.description; obj1.flag = 1; obj1.create_time = DateTime.Now; _context.Location.Add(obj1); _context.SaveChanges(); msg.Title = "Thêm thành công"; } catch (Exception ex) { msg.Error = true; msg.Object = ex; msg.Title = "Có lỗi khi thêm "; } return(Json(msg)); }
public JsonResult Insert([FromBody] EDMSMaterialProduct obj) { var msg = new JMessage { Title = "", Error = false }; try { var model = _context.EDMSMaterialProducts.Where(x => x.ProductCode.Equals(obj.ProductCode)).FirstOrDefault(); if (model == null) { //obj.CreatedBy = ESEIM.AppContext.UserName; obj.CreatedTime = DateTime.Now; _context.EDMSMaterialProducts.Add(obj); _context.SaveChanges(); msg.Title = "Thêm vật tư thành công"; } else { msg.Error = true; msg.Title = "Mã vật tư đã tồn tại!"; } } catch { msg.Error = true; msg.Title = "Thêm vật tư lỗi!"; } return(Json(msg)); }
public JsonResult insert([FromBody] edu_class obj) { var msg = new JMessage() { Error = false }; try { var query = from a in _context.edu_class where a.code == obj.code select a; if (query.Count() == 0) { edu_class obj1 = new edu_class(); obj1.code = obj.code; obj1.name = obj.name; obj1.idcrouse = obj.idcrouse; // obj1.Birthday = Convert.ToDateTime(obj.Birthday); obj1.numberstudent = obj.numberstudent; obj1.schoolstart = obj.schoolstart; obj1.schoolend = obj.schoolend; obj1.schoolday = obj.schoolday; obj1.status = obj.status; obj1.classroom_id = obj.classroom_id; obj1.teacher_id = obj.teacher_id; obj1.fee = obj.fee; obj1.datestart = obj.datestart; obj1.dateend = obj.dateend; obj1.sale_off_price = obj.sale_off_price; obj1.start_sale_off = obj.start_sale_off; obj1.end_sale_off = obj.end_sale_off; obj1.sale_off_note = obj.sale_off_note; obj1.location_id = obj.location_id; obj1.flag = 1; obj1.creattime = DateTime.Now; _context.edu_class.Add(obj1); _context.SaveChanges(); msg.Title = "Thêm thành công"; } else { msg.Error = true; msg.Title = "Mã đã tồn tại"; } } catch (Exception ex) { msg.Error = true; msg.Object = ex; msg.Title = "Có lỗi khi thêm "; } return(Json(msg)); }
public JsonResult Insert([FromBody] AppVendor obj) { var msg = new JMessage() { Error = false, Title = "" }; try { var checkExist = _context.AppVendors.FirstOrDefault(x => x.VendorCode.ToLower() == obj.VendorCode.ToLower()); if (checkExist != null) { msg.Error = true; msg.Title = String.Format(CommonUtil.ResourceValue("COM_MSG_EXITS"), CommonUtil.ResourceValue("AVD_CURD_LBL_CODE")); } else { _context.AppVendors.Add(obj); _context.SaveChanges(); msg.Title = String.Format(CommonUtil.ResourceValue("COM_MSG_ADD_SUCCESS"), CommonUtil.ResourceValue("AVD_MSG_PARTNER")); } } catch (Exception ex) { msg.Error = true; msg.Title = String.Format(CommonUtil.ResourceValue("COM_ERR_FAIL_ADD"), CommonUtil.ResourceValue("AVD_MSG_PARTNER")); } return(Json(msg)); }
public JsonResult Insert([FromBody] ServiceCategory obj) { var msg = new JMessage { Error = false, Title = "" }; try { var checkExist = _context.ServiceCategorys.FirstOrDefault(x => x.ServiceCode == obj.ServiceCode); if (checkExist == null) { obj.CreatedBy = ESEIM.AppContext.UserName; obj.CreatedTime = DateTime.Now; _context.ServiceCategorys.Add(obj); _context.SaveChanges(); msg.Title = String.Format(CommonUtil.ResourceValue("COM_MSG_ADD_SUCCESS"), CommonUtil.ResourceValue("SVC_TITLE_SERVICE")); } else { msg.Error = true; msg.Title = String.Format(CommonUtil.ResourceValue("COM_MSG_EXITS"), CommonUtil.ResourceValue("SVC_CURE_LBL_CODE")); } } catch { msg.Error = true; msg.Title = String.Format(CommonUtil.ResourceValue("COM_MSG_ADD_FAILED"), CommonUtil.ResourceValue("SVC_TITLE_SERVICE")); } return(Json(msg)); }
public JsonResult insert([FromBody] edu_student obj) { var msg = new JMessage() { Error = false }; try { edu_student obj1 = new edu_student(); obj1.facebook = obj.facebook; obj1.sky = obj.sky; obj1.google = obj.google; // obj1.Birthday = Convert.ToDateTime(obj.Birthday); obj1.twitter = obj.twitter; obj1.wordpress = obj.wordpress; obj1.other = obj.other; obj1.flag = 1; obj1.createtime = DateTime.Now; _context.edu_student.Add(obj1); _context.SaveChanges(); msg.Title = "Thêm thành công"; } catch (Exception ex) { msg.Error = true; msg.Object = ex; msg.Title = "Có lỗi khi thêm "; } return(Json(msg)); }
public object Insert([FromBody] CommonSetting data) { var msg = new JMessage() { Error = false }; try { var checkExist = _context.CommonSettings.FirstOrDefault(x => x.CodeSet.ToLower() == data.CodeSet.ToLower()); if (checkExist != null) { msg.Error = true; msg.Title = "Mã cài đặt đã tồn tại!"; } else { data.CreatedBy = ESEIM.AppContext.UserName; data.CreatedTime = DateTime.Now; _context.CommonSettings.Add(data); _context.SaveChanges(); msg.Title = "Thêm mới cài đặt thành công"; } } catch (Exception ex) { msg.Error = true; msg.Title = "Có lỗi xảy ra khi thêm!"; } return(Json(msg)); }
public JsonResult Insert([FromBody] MaterialProduct obj) { var msg = new JMessage { Title = "", Error = false }; try { var model = _context.MaterialProducts.Where(x => x.ProductCode.Equals(obj.ProductCode)).FirstOrDefault(); if (model == null) { obj.CreatedBy = ESEIM.AppContext.UserName; obj.CreatedTime = DateTime.Now; _context.MaterialProducts.Add(obj); _context.SaveChanges(); msg.Title = String.Format(CommonUtil.ResourceValue("COM_MSG_ADD_SUCCESS"), CommonUtil.ResourceValue("MLP_MSG_SUPPLIES")); } else { msg.Error = true; msg.Title = String.Format(CommonUtil.ResourceValue("COM_MSG_EXITS"), CommonUtil.ResourceValue("MLP_CURD_LBL_SUPPLIES_CODE")); } } catch { msg.Error = true; msg.Title = String.Format(CommonUtil.ResourceValue("COM_MSG_ADD_FAILED"), CommonUtil.ResourceValue("MLP_MSG_SUPPLIES")); } return(Json(msg)); }
public JsonResult CheckIn([FromBody] SStaffTimeKeepingModel obj) { var msg = new JMessage { Error = false, Title = "" }; try { var model = new StaffTimetableWorking { UserId = obj.UserId, Action = "CHECKIN", ActionTime = DateTime.Now, Note = obj.Note, }; _context.StaffTimetableWorkings.Add(model); _context.SaveChanges(); msg.Title = "Checkin thành công!"; } catch (Exception ex) { msg.Error = true; msg.Title = "Checkin lỗi!"; } return(Json(msg)); }
public JsonResult Insert([FromBody] IotWarningSetting data) { var msg = new JMessage() { Error = false }; try { var checkExist = _context.IotWarningSettings.FirstOrDefault(x => x.ObjType.ToLower() == data.ObjType.ToLower()); if (checkExist != null) { msg.Error = true; msg.Title = "Đã tồn tại cấu hình tham số!"; } else { data.CreatedBy = ESEIM.AppContext.UserName; data.CreatedTime = DateTime.Now; _context.IotWarningSettings.Add(data); _context.SaveChanges(); msg.Title = "Thêm cấu hình tham số thành công"; } } catch (Exception ex) { msg.Error = true; msg.Title = "Có lỗi xảy ra khi thêm?"; } return(Json(msg)); }
public JsonResult Insert([FromBody] AssetActivity data) { var msg = new JMessage() { Error = false }; try { var checkExist = _context.AssetAtivitys.FirstOrDefault(x => x.ActCode.ToLower() == data.ActCode.ToLower()); if (checkExist != null) { msg.Error = true; msg.Title = "Đã tồn tại mã hoạt động!"; } else { data.CreatedBy = ESEIM.AppContext.UserName; data.CreatedTime = DateTime.Now; _context.AssetAtivitys.Add(data); _context.SaveChanges(); msg.Title = "Thêm hoạt động thành công"; } } catch (Exception ex) { msg.Error = true; msg.Title = "Có lỗi xảy ra khi thêm?"; } return(Json(msg)); }
public JsonResult SetInterviewDate([FromBody] Interview data) { var msg = new JMessage() { Error = true }; try { if (data == null) { msg.Title = "Chọn ngày phỏng vấn!"; return(Json(msg)); } if (string.IsNullOrEmpty(data.CandidateCode)) { msg.Title = "Chọn mã candidate!"; return(Json(msg)); } var query = _context.CandidateInterviews.Where(x => x.CandidateCode.Equals(data.CandidateCode)); if (query.Count() > 0) { var a = _context.CandidateInterviews.FirstOrDefault(x => x.CandidateCode.Equals(data.CandidateCode)); a.InterviewDate = data.InterviewDate; _context.CandidateInterviews.Update(a); _context.SaveChanges(); msg.Error = false; msg.Title = "Cập nhật lịch thành công"; return(Json(msg)); } CandidateInterview obj = new CandidateInterview() { CandidateCode = data.CandidateCode, //InterviewDate = DateTime.ParseExact(data.InterviewDate.Replace(' ', 'T'), "dd/MM/yyyy", CultureInfo.InvariantCulture) InterviewDate = data.InterviewDate }; _context.CandidateInterviews.Add(obj); _context.SaveChanges(); msg.Error = false; msg.Title = "Cập nhật thành công!"; return(Json(msg)); } catch (Exception ex) { msg.Object = ex; msg.Title = "Có lỗi xảy ra!"; return(Json(msg)); throw; } }
public JsonResult Insert(CustomerRequestModel obj, IFormFile fileUpload) { var msg = new JMessage() { Error = false, Title = "" }; try { if (fileUpload != null) { var upload = _upload.UploadFile(fileUpload, Path.Combine(_hostingEnvironment.WebRootPath, "uploads\\files")); if (!upload.Error) { var customerRequest = new OrderRequestRaw { Title = obj.Title, Content = obj.Content, Phone = obj.Phone, Keyword = obj.Keyword, Priority = obj.Priority, CreatedTime = DateTime.Now, RequestTime = !string.IsNullOrEmpty(obj.RequestTime) ? DateTime.ParseExact(obj.RequestTime, "dd/MM/yyyy", CultureInfo.InvariantCulture) : (DateTime?)null, FileName1 = fileUpload.FileName, File1 = "/uploads/files/" + upload.Object.ToString(), }; _context.OrderRequestRaws.Add(customerRequest); _context.SaveChanges(); msg.Title = "Đã thêm yêu cầu thành công"; } } else { var customerRequest = new OrderRequestRaw { Title = obj.Title, Content = obj.Content, Phone = obj.Phone, Email = obj.Email, Keyword = obj.Keyword, Priority = obj.Priority, CreatedTime = DateTime.Now, RequestTime = !string.IsNullOrEmpty(obj.RequestTime) ? DateTime.ParseExact(obj.RequestTime, "dd/MM/yyyy", CultureInfo.InvariantCulture) : (DateTime?)null, }; _context.OrderRequestRaws.Add(customerRequest); _context.SaveChanges(); msg.Title = "Đã thêm yêu cầu thành công"; } } catch (Exception ex) { msg.Error = true; msg.Title = "Thêm yêu cầu lỗi"; } return(Json(msg)); }
public JsonResult InsertEventCat([FromBody] EventCatUser data) { var msg = new JMessage() { Error = false, Title = "" }; try { var fromDate = DateTime.ParseExact(data.FromDate, "dd/MM/yyyy", CultureInfo.InvariantCulture); var toDate = DateTime.ParseExact(data.ToDate, "dd/MM/yyyy", CultureInfo.InvariantCulture); var appointmentTime = string.IsNullOrEmpty(data.AppointmentTime) ? DateTime.ParseExact(data.ToDate, "dd/MM/yyyy", CultureInfo.InvariantCulture) : (DateTime?)null; var employess = _context.HREmployees.FirstOrDefault(x => x.Id.ToString() == data.MemberId); if (employess != null) { //insert,update event var listEvent = _context.StaffScheduleWorks.Where(x => x.MemberId == data.MemberId); if (listEvent.Any()) { _context.StaffScheduleWorks.RemoveRange(listEvent); } for (DateTime date = fromDate; date <= toDate; date = date.AddDays(1)) { string frameTime = data.Morning.ToString() + ";" + data.Afternoon.ToString() + ";" + data.Evening.ToString(); var evt = new StaffScheduleWork { MemberId = data.MemberId, FrameTime = frameTime, CreatedBy = ESEIM.AppContext.UserName, CreatedTime = DateTime.Now, DatetimeEvent = date, }; _context.StaffScheduleWorks.Add(evt); } _context.SaveChanges(); msg.Title = "Đăng ký thành công!"; } else { msg.Error = true; msg.Title = "Nhân viên không tồn tại!"; } } catch (Exception ex) { msg.Error = true; msg.Object = ex; msg.Title = "Có lỗi xảy ra đăng ký!"; } return(Json(msg)); }
public JsonResult Insert([FromBody] AdOrganization obj) { //_logger.LogInformation(LoggingEvents.LogDb, "Insert Organization"); var msg = new JMessage() { Error = false }; try { var org = _context.AdOrganizations.Where(x => x.OrgCode.Equals(obj.OrgCode)).FirstOrDefault(); //var org = _context.AdOrganizations.Where(x => int.Parse(x.OrgCode).Equals(int.Parse(obj.OrgCode))).FirstOrDefault(); if (org == null) { var adOrganizations = new AdOrganization { Division = int.Parse(obj.Division) > 0 ? obj.Division : string.Concat("0", obj.Division), OrgCode = obj.OrgCode, OrgName = obj.OrgName, OrgAddonCode = "b_" + obj.OrgCode, OrgGroup = 2, OrgUpdateTime = DateTime.Now.ToString(), Company = "BRA", Country = "VN", State = "01", HierarchyCode = "11", IsEnabled = true, OrgId = _context.AdOrganizations.Max(x => x.OrgId) + 1 }; //msg.Title = "Thêm Chi nhánh thành công !"; msg.Title = String.Format(CommonUtil.ResourceValue("COM_MSG_ADD_SUCCESS"), CommonUtil.ResourceValue("ADM_BRANCH_LBL_BRANCH").ToLower()); _context.AdOrganizations.Add(adOrganizations); _context.SaveChanges(); //_logger.LogInformation(LoggingEvents.LogDb, "Insert Organization Success"); _actionLog.InsertActionLog("AdOrganization", "Insert Organization Success", null, obj, "Insert"); } else { msg.Error = true; //msg.Title = "Chi nhánh đã tồn tại!"; msg.Title = String.Format(CommonUtil.ResourceValue("COM_MSG_EXITS"), CommonUtil.ResourceValue("ADM_BRANCH_LBL_BRANCH")); } } catch (Exception ex) { msg.Error = true; //msg.Title = "Thêm Chi nhánh thất bại !"; msg.Title = String.Format(CommonUtil.ResourceValue("COM_MSG_ADD_FAILED"), CommonUtil.ResourceValue("ADM_BRANCH_LBL_BRANCH")); //_logger.LogError(LoggingEvents.LogDb, "Insert Organization Fail"); _actionLog.InsertActionLog("AdOrganization", "Insert Organization Fail", null, null, "Error"); } return(Json(msg)); }
////insert dữ liệu //[HttpPost] //public JsonResult insert([FromBody]edu_course obj) //{ // var msg = new JMessage() { Error = false }; // try // { // var query = from a in _context.edu_course // where a.course_code == obj.course_code // select a; // if(query.Count() == 0) // { // edu_course obj1 = new edu_course(); // obj1.course_code = obj.course_code; // obj1.course_name = obj.course_name; // obj1.coursetype = obj.coursetype; // // obj1.Birthday = Convert.ToDateTime(obj.Birthday); // obj1.note = obj.note; // obj1.price = obj.price; // obj1.totalday = obj.totalday; // obj1.userid = obj.userid; // obj1.level = obj.level; // obj1.flag = 1; // obj1.createtime = DateTime.Now; // _context.edu_course.Add(obj1); // _context.SaveChanges(); // msg.Title = "Thêm thành công"; // } // else // { // msg.Error = true; // msg.Title = "Mã đã tồn tại"; // } // } // catch (Exception ex) // { // msg.Error = true; // msg.Object = ex; // msg.Title = "Có lỗi khi thêm "; // } // return Json(msg); //} ////update dữ liệu //[HttpPost] //public JsonResult update([FromBody]edu_course obj) //{ // var msg = new JMessage() { Error = true }; // try // { // var rs = _context.edu_course.SingleOrDefault(x => x.id == obj.id); // if (rs != null) // { // rs.id = obj.id; // rs.course_name = obj.course_name; // rs.note = obj.note; // rs.coursetype = obj.coursetype; // rs.updatetime = DateTime.Now; // rs.price = obj.price; // rs.userid = obj.userid; // rs.course_code = obj.course_code; // rs.totalday = obj.totalday; // rs.level = obj.level; // _context.edu_course.Update(rs); // _context.SaveChanges(); // msg.Title = "Cập nhật thông tin thành công"; // msg.Error = false; // } // } // catch (Exception ex) // { // msg.Object = ex; // msg.Title = "Có lỗi khi cập nhật"; // } // return Json(msg); //} public async Task <JsonResult> Insert(edu_cat_ranking obj, IFormFile picture) { var msg = new JMessage() { Error = false, ID = 1 }; try { var icpicture = ""; if (picture != null && picture.Length > 0) { var pathUpload = Path.Combine(_hostingEnvironment.WebRootPath, "pictures\\avatar"); if (!Directory.Exists(pathUpload)) { Directory.CreateDirectory(pathUpload); } var fileName = DateTimeOffset.Now.ToUnixTimeMilliseconds() + picture.FileName; var filePath = Path.Combine(pathUpload, fileName); using (var stream = new FileStream(filePath, FileMode.Create)) { await picture.CopyToAsync(stream); } icpicture = "/pictures/avatar/" + fileName; } if (icpicture != "") { obj.picture = icpicture; } obj.createtime = DateTime.Now; obj.flag = 1; _context.edu_cat_ranking.Add(obj); _context.SaveChanges(); msg.Title = "Thêm mới xếp hạng thành công"; msg.Error = false; _actionLog.InsertActionLog("edu_cat_ranking", "Insert new edu_cat_ranking successfully", null, obj, "Insert"); } catch (Exception ex) { msg.ID = 0; msg.Error = true; msg.Object = ex; msg.Title = "Có lỗi khi thêm khoản mục"; _actionLog.InsertActionLog("edu_cat_ranking", "Insert new edu_cat_ranking fail", null, obj, "Insert"); } return(Json(msg)); }
public JsonResult Send([FromBody] IncommingDispatchesModel obj) { var msg = new JMessage { Title = "", Error = false }; try { string processCode = ""; var userId = ESEIM.AppContext.UserId; var dispatchess = _context.DispatchesHeaders.FirstOrDefault(x => x.Id == obj.Header.Id); var tracking = _context.DispatchTrackingProcesss.FirstOrDefault(x => x.DispatchCode == dispatchess.DispatchCode); if (tracking != null) { var trackingNew = new DispatchTrackingProcess { DispatchCode = dispatchess.DispatchCode, ProcessCode = tracking.ProcessCode, Action = EnumHelper <DocumentStatusEnum> .GetDisplayValue(DocumentStatusEnum.Send), CreatedTime = DateTime.Now, //Reason = obj.Detail.Reason, UserId = userId, //Status = tracking.Status, }; _context.DispatchTrackingProcesss.Add(trackingNew); processCode = tracking.ProcessCode; } var listMemberNew = obj.Detail.ListMember.Where(x => x.IsShowDelete == true); foreach (var member in listMemberNew) { var activity = new DispatchesMemberActivity { Assigner = userId, ProcessCode = processCode, UserId = member.UserId, CreatedTime = DateTime.Now, Role = DocumentRoleEnum.Support.GetHashCode() }; _context.DispatchesMemberActivitys.Add(activity); } _context.SaveChanges(); msg.Title = String.Format(CommonUtil.ResourceValue("DODP_MSG_UPDATE_SUCCESS")); } catch { msg.Error = true; msg.Title = String.Format(CommonUtil.ResourceValue("DODP_MSG_UPDATE_FAIL")); } return(Json(msg)); }
public JsonResult insert([FromBody] test obj) { var msg = new JMessage() { Error = false }; try { var query = from a in _context.edu_student where a.code == obj.code select a; if (query.Count() == 0) { edu_student obj1 = new edu_student(); obj1.code = obj.code; obj1.firstname = obj.firstname; obj1.sex = obj.sex; // obj1.Birthday = Convert.ToDateTime(obj.Birthday); obj1.birthday = obj.birthday; obj1.flag = 1; obj1.createtime = DateTime.Now; _context.edu_student.Add(obj1); _context.SaveChanges(); edu_student_contact obj2 = new edu_student_contact(); var rs = _context.edu_student.OrderByDescending("id").FirstOrDefault(); obj2.studentID = rs.id; obj2.flag = 1; obj2.relationship = obj.relationship; obj2.name = obj.name; _context.edu_student_contact.Add(obj2); _context.SaveChanges(); msg.Title = "Thêm thành công"; } else { msg.Error = true; msg.Title = "Mã đã tồn tại"; } } catch (Exception ex) { msg.Error = true; msg.Object = ex; msg.Title = "Có lỗi khi thêm "; } return(Json(msg)); }
public object Insert([FromBody] ParamForWarningModel data) { var msg = new JMessage() { Error = false }; try { var fromDate = !string.IsNullOrEmpty(data.FromTime) ? DateTime.ParseExact(data.FromTime, "dd/MM/yyyy", CultureInfo.InvariantCulture) : (DateTime?)null; var toDate = !string.IsNullOrEmpty(data.ToTime) ? DateTime.ParseExact(data.ToTime, "dd/MM/yyyy", CultureInfo.InvariantCulture) : (DateTime?)null; var model = _context.ParamForWarnings.FirstOrDefault(x => x.aetType.ToLower() == data.AETType.ToLower() && x.catCode.ToLower() == data.CatCode.ToLower() && ((fromDate >= x.fromTime && fromDate < x.toTime) || (toDate <= x.toTime && toDate > x.fromTime)) && x.isDeleted == false); if (model == null) { var obj = new ParamForWarning { aetType = data.AETType, createdTime = DateTime.Now, catCode = data.CatCode, currency = data.Currency, total = decimal.Parse(data.Total), createdBy = ESEIM.AppContext.UserName, fromTime = fromDate, toTime = toDate }; //data.CreatedBy = ESEIM.AppContext.UserName; //data.CreatedTime = DateTime.Now; _context.ParamForWarnings.Add(obj); _context.SaveChanges(); msg.Title = String.Format(CommonUtil.ResourceValue("PFW_MSG_ADD_WARNING_SUCCESS"));// thêm canh bao thành công } else { msg.Error = true; msg.Title = String.Format(CommonUtil.ResourceValue("PFW_MSG_WARNING_EXITS"));//"Cảnh báo đã tồn tại"; } return(Json(msg)); } catch (Exception ex) { msg.Error = true; msg.Title = String.Format(CommonUtil.ResourceValue("PFW_MSG_ADD_WARNING_FAIL")); //"Có lỗi xảy ra khi thêm!"; msg.Object = ex; return(Json(msg)); } }
public JsonResult Insert(PackingModel obj, IFormFile pictureFile) { var msg = new JMessage { Error = false, Title = "" }; try { if (pictureFile != null && pictureFile.Length > 0) { _upload.UploadImage(pictureFile); } var model = new MapDataGps { Title = obj.title, Icon = obj.Icon, //Icon = obj.Icon.Contains("SHOP") ? SHOP_ICON : obj.Icon.Contains("PAGODA") ? PAGODA_ICON : obj.Icon.Contains("PARK") ? PARK_ICON : obj.Icon.Contains("COMPANY") ? COMPANY_ICON : null, PolygonGPS = obj.Gis_data, }; _context.MapDataGpss.Add(model); _context.SaveChanges(); msg.Title = "Thêm mới địa điểm thành công"; } catch (Exception ex) { msg.Error = true; msg.Title = "Thêm mới địa điểm lỗi"; } return(Json(msg)); }
public object Delete(int id) { var msg = new JMessage() { Error = false }; try { var data = _context.AssetAtivitys.FirstOrDefault(x => x.ActivityId == id); data.DeletedBy = ESEIM.AppContext.UserName; data.DeletedTime = DateTime.Now; data.IsDeleted = true; _context.AssetAtivitys.Update(data); _context.SaveChanges(); msg.Title = "Xóa thành công"; return(Json(msg)); } catch (Exception ex) { msg.Error = true; msg.Title = "Có lỗi xảy ra khi xóa!"; msg.Object = ex; return(Json(msg)); } }
public JsonResult Insert([FromBody] AssetTransferHeadersJtableModel obj) { var msg = new JMessage { Title = "", Error = false }; try { DateTime?startTime = !string.IsNullOrEmpty(obj.StartTime) ? DateTime.ParseExact(obj.StartTime, "dd/MM/yyyy", CultureInfo.InvariantCulture) : (DateTime?)null; DateTime?receivedTime = !string.IsNullOrEmpty(obj.ReceivedTime) ? DateTime.ParseExact(obj.ReceivedTime, "dd/MM/yyyy", CultureInfo.InvariantCulture) : (DateTime?)null; var data = _context.AssetTransferHeaders.FirstOrDefault(x => x.Ticketcode == obj.Ticketcode && x.IsDeleted == false); if (data == null) { var dt = new AssetTransferHeader(); dt.Ticketcode = obj.Ticketcode; dt.Ticket = obj.Ticket; dt.DepartTransf = obj.DepartTransf; dt.DepartReceived = obj.DepartReceived; dt.UserTransf = obj.UserTransf; dt.UserReceived = obj.UserReceived; dt.LocationTransf = obj.LocationTransf; dt.ReceivedLocation = obj.ReceivedLocation; dt.Note = obj.Note; dt.StartTime = startTime; dt.ReceivedTime = receivedTime; dt.CreatedBy = ESEIM.AppContext.UserName; dt.CreatedTime = DateTime.Now; dt.Status = obj.Status; // dt.fullname = obj.fullname; _context.AssetTransferHeaders.Add(dt); _context.SaveChanges(); msg.Title = String.Format(CommonUtil.ResourceValue("SUCCESS") /*, CommonUtil.ResourceValue("DCD_MSG_TITLE_DCD")*/); } else { msg.Error = true; msg.Title = String.Format(CommonUtil.ResourceValue("OK"));/*DCD_MSG_DOCUMENT_NOT*/ } } catch (Exception) { msg.Error = true; // msg.Title = String.Format(CommonUtil.ResourceValue("COM_MSG_ADD_FAILED")/*, CommonUtil.ResourceValue("DCD_MSG_TITLE_DCD")*/); msg.Title = "lỗi"; } return(Json(msg)); }