public string UpdateManagers(Dictionary <string, string> user_manager) { Employee temp = new Employee(); try { foreach (var listitem in user_manager) { if (!string.IsNullOrEmpty(listitem.Key) && !string.IsNullOrEmpty(listitem.Value.Trim())) { var item = GetSession.Get <Employee>(Convert.ToInt64(listitem.Key)); var item2 = GetSession.Get <Employee>(Convert.ToInt64(listitem.Value)); if (item != null) { item.Manager = item2; GetSession.Update(item); } } } return("yes"); } catch (Exception) { return("no"); } }
public ActionResult Update(ForumItemModel model) { ForumItem forumTarget = GetSession.Get <ForumItem>(Convert.ToInt64(Request.Form["Id"])); forumTarget.Admin = GetSession.Get <Employee>(Convert.ToInt64(Request.Form["Admin"])); forumTarget.Title = Request.Form["Title"]; forumTarget.Active = (Request.Form["Active"] == "on") ? true : false; GetSession.Update(forumTarget); #region ADO.NET //string theTitle = Request.Form["Title"]; //long theAdmin = Convert.ToInt32(Request.Form["Admin"]); //long theId = Convert.ToInt32(Request.Form["Id"]); //bool theActive = (Request.Form["Active"] == "on") ? true : false; //SqlConnection sqlConnection1 = new SqlConnection(cs); //SqlCommand cmd = new SqlCommand(); //Int32 rowsAffected; //cmd.CommandText = "UPDATE portal_ForumItem SET Title = '" + theTitle + "', Admin_id = " + theAdmin + ", Active = '" + theActive + "' WHERE Id = " + theId + ""; ////cmd.CommandText = "UPDATE portal_ForumItem SET Title = '" + theTitle + "', Admin_id = " + theAdmin + ", Active = '" + theActive + "' WHERE Id = "+theId+""; //cmd.CommandType = CommandType.Text; //cmd.Connection = sqlConnection1; //sqlConnection1.Open(); //rowsAffected = cmd.ExecuteNonQuery(); //sqlConnection1.Close(); #endregion return(Redirect("/ForumItems/")); }
public ContentResult PageActive(long id, bool isActive) { var item = GetSession.Get <Page>(id); item.IsActive = isActive; GetSession.Update(item); return(Content("ok")); }
public ActionResult ActiveForderUploadActive(bool isActive) { var item = GetSession.Get <Setting>((long)1); item.ActiveForderUpload = isActive; GetSession.Update(item); return(Content("ok")); }
public ContentResult bdaymailsIsAllow(bool isActive) { var model = GetSession.Get <Setting>((long)1); model.BDayEmailsAllow = isActive; GetSession.Update(model); return(Content("ok")); }
public ContentResult FlashBannerActive(long id, bool isActive) { var item = GetSession.Get <FlashBanner>(id); item.IsActive = isActive; GetSession.Update(item); return(Content("ok")); }
public ContentResult PageOrder(long id, int pageOrder) { var item = GetSession.Get <Page>(id); item.PageOrder = pageOrder; GetSession.Update(item); return(Content("ok")); }
public ActionResult Edit(long id, HttpPostedFileBase boxFile, HttpPostedFileBase bdate, HttpPostedFileBase box1, HttpPostedFileBase box2, HttpPostedFileBase box3, HttpPostedFileBase box4) { var item = GetSession.Get <Setting>(id); var homePath = Server.MapPath("~/public/userfiles/home/boximage.jpg"); if (boxFile != null) { boxFile.SaveAs(string.Format(homePath)); } homePath = Server.MapPath("~/public/userfiles/home/bdate.jpg"); if (bdate != null) { bdate.SaveAs(string.Format(homePath)); } homePath = Server.MapPath("~/public/userfiles/home/box1.jpg"); if (box1 != null) { var image = new WebImage(box1.InputStream); image.Resize(500, 212).Crop(1, 1).Save(string.Format(homePath)); } homePath = Server.MapPath("~/public/userfiles/home/box2.jpg"); if (box2 != null) { var image = new WebImage(box2.InputStream); image.Resize(500, 212).Crop(1, 1).Save(string.Format(homePath)); } homePath = Server.MapPath("~/public/userfiles/home/box3.jpg"); if (box3 != null) { var image = new WebImage(box3.InputStream); image.Resize(500, 212).Crop(1, 1).Save(string.Format(homePath)); } homePath = Server.MapPath("~/public/userfiles/home/box4.jpg"); if (box4 != null) { var image = new WebImage(box4.InputStream); image.Resize(500, 212).Crop(1, 1).Save(string.Format(homePath)); } UpdateModel(item); GetSession.Update(item); return(RedirectToAction("Edit")); }
public ActionResult Edit(GalleryFormModel model) { var item = GetSession.Get <Gallery>(model.Id); Mapper.Map <GalleryFormModel, Gallery>(model, item); GetSession.Update(item); return(RedirectToAction("Index")); }
public ActionResult Edit(CalendarFormModel model) { var item = GetSession.Get <Calendar>(model.Id); Mapper.Map <CalendarFormModel, Calendar>(model, item); GetSession.Update(item); return(RedirectToAction("Index")); }
public ActionResult Permissions(PermissionsFormModel model) { var item = GetSession.Get <Page>(model.Id); Mapper.Map <PermissionsFormModel, Page>(model, item); GetSession.Update(item); return(RedirectToAction("Index", new { model.ParentId, model.SectionId })); }
public ActionResult UpdatePostContent(string postContent) { var item = GetSession.Get <Employee>(GetEmployeeId); item.PostContent = postContent; GetSession.Update(item); return(RedirectToAction("Card", new { item.Id })); }
public ActionResult UpdateAlias(string alias) { var item = GetSession.Get <Employee>(GetEmployeeId); item.Alias = alias; GetSession.Update(item); return(RedirectToAction("Card", new { item.Id })); }
public ActionResult BannerOrder(long id, int bannerOrder) { var item = GetSession.Get <FlashBanner>(id); item.BannerOrder = bannerOrder; GetSession.Update(item); return(new EmptyResult()); }
public ContentResult ForumTitle(long categoryId, string title) { var forums = GetSession.QueryOver <Forum>() .Where(x => x.CategoryId == categoryId).List(); foreach (Forum forum in forums) { forum.CategoryTitle = title; GetSession.Update(forum); } return(Content("ok")); }
public ActionResult Edit(JobFormModel model) { if (ModelState.IsValid) { var item = GetSession.Get <Job>(model.Id); Mapper.Map <JobFormModel, Job>(model, item); GetSession.Update(item); return(RedirectToAction("Index")); } return(View(model)); }
public ActionResult Edit(DepartmentFormModel model) { var item = GetSession.Get <Department>(model.Id); if (ModelState.IsValid) { Mapper.Map <DepartmentFormModel, Department>(model, item); GetSession.Update(item); return(RedirectToAction("Index")); } return(View(model)); }
public ActionResult Edit(PollItemFormModel model) { var item = GetSession.Get <PollItem>(model.Id); if (ModelState.IsValid) { Mapper.Map <PollItemFormModel, PollItem>(model, item); GetSession.Update(item); return(Redirect(Url.RouteUrl(new { controller = "Polls", action = "Edit", id = model.Poll_Id }) + "#items")); //return RedirectToAction("Edit", "Polls", new { id = model.Poll_Id }); } return(View(model)); }
public ActionResult Edit(PageFormModel model) { if (ModelState.IsValid) { var item = GetSession.Get <Page>(model.Id); Mapper.Map <PageFormModel, Page>(model, item); item.UpdatedDate = DateTime.Now; GetSession.Update(item); return(RedirectToAction("Index", new { model.ParentId, model.SectionId })); } return(View(model)); }
public ActionResult Edit(EmployeeFormModel model) { if (ModelState.IsValid) { var item = GetSession.Get <Employee>(model.Id); Mapper.Map <EmployeeFormModel, Employee>(model, item); GetSession.Update(item); return(RedirectToAction("List")); } model.InitMembers(GetSession); return(View(model)); }
public ActionResult Edit(PollFormModel model) { var item = GetSession.Get <Poll>(model.Id); //bool anonymous = model.Anonymous; //if (!model.Anonymous && item.Anonymous) //{ // if (item.PollItems.Any(pi => pi.EmployeePollItems.Count > 0)) // { // anonymous = true; // } //} if (ModelState.IsValid) { Mapper.Map <PollFormModel, Poll>(model, item); item.Anonymous = model.Anonymous; // Object if (model.Object_id > 0) { item.Object = GetSession.Get <Poll>(model.Object_id); } else { item.Object = null; } // Anonymous User if (model.AnonymousUser_id > 0) { item.AnonymousUser = GetSession.Get <Employee>(model.AnonymousUser_id); } else { item.AnonymousUser = null; } GetSession.Update(item); return(RedirectToAction("Index")); } return(View(model)); }
public ActionResult Card(long id) { var item = GetSession.Get <Employee>(id); if (item.Username == Employee.GetUsername && Employee.Current.EmployeeMessagesCount > 0) { foreach (var msg in item.EmployeeMessages.Where(x => !x.IsRead)) { msg.IsRead = true; GetSession.Update(msg); } Employee.Current.EmployeeMessagesCount = 0; Session["employee"] = Employee.Current; } return(View(item)); }
public ContentResult DocAction(string user, long doc) { var item = GetSession.Get <Doc>(doc); if (string.IsNullOrEmpty(item.Submited)) { item.Submited = item.Submited + user; } else { item.Submited = item.Submited + "," + user; } item.NotSubmited = (GetSession.QueryOver <Employee>().List().Count() - item.Submited.Split(',').Length).ToString(); GetSession.Update(item); return(Content("ok")); }
public ActionResult Edit(DocFormModel model, HttpPostedFileBase upload_file) { if (ModelState.IsValid) { var item = GetSession.Get <Doc>(model.Id); if (upload_file != null) { var uploaded_file = Guid.NewGuid(); var u_file = upload_file.InputStream; int index = upload_file.FileName.IndexOf('.'); string new_name = uploaded_file + "." + upload_file.FileName.Substring(index + 1); var path = Path.Combine(Server.MapPath("~/Public/userfiles/docs"), new_name); upload_file.SaveAs(path); model.Url = new_name; } Mapper.Map <DocFormModel, Doc>(model, item); if (Request.Form["UsersListEdit"] != null) { item.UsersAllowed = Request.Form["UsersListEdit"].ToString(); } if (Request.Form["Units[]"] != null) { item.Units = Request.Form["Units[]"].ToString(); } if (string.IsNullOrEmpty(Request.Form["Units[]"])) { item.Units = "0"; } GetSession.Update(item); return(RedirectToAction("Index")); } return(View(model)); }
public ActionResult UpdateEmployeesPhotos() { var items = GetSession.QueryOver <Employee>().List(); int sum = 0; foreach (Employee item in items) { var emp = GetSession.Get <Employee>(item.Id); emp.Picture = emp.Id.ToString() + ".jpg"; if (emp.BDay == null) { emp.BDay = DateTime.Now; } GetSession.Update(item); sum += 1; } return(Content("done : updated -> " + sum)); }
public ActionResult Edit(FlashBannerFormModel model, HttpPostedFileBase uploadPicture) { var item = GetSession.Get <FlashBanner>(model.Id); Mapper.Map <FlashBannerFormModel, FlashBanner>(model, item); if (uploadPicture != null && uploadPicture.ContentLength > 0) { if (model.TypeId == 1) { item.Banner += "|" + SaveFile(uploadPicture, "flashBanners", item.Banner); } else { item.Banner = SaveFile(uploadPicture, "flashBanners", item.Banner); } } GetSession.Update(item); return(RedirectToAction("Index")); }
public ActionResult UpdateEmployees() { ////----------------- //string filePaths = @"E:\Users\max\Desktop\Development\ON AIR SITES\New Sites Online_Alex\Zoglobek PORTAL\Source\Portal.Web.UI.Application\Public\userfiles\SOGPORTAL.xlsx"; //string strFile = @"E:\Users\max\Desktop\Development\ON AIR SITES\New Sites Online_Alex\Zoglobek PORTAL\Source\Portal.Web.UI.Application\Public\userfiles\SOGPORTAL.xlsx"; //string strTemp = Path.GetExtension(strFile).ToLower(); //if (strTemp == ".xls") //{ // strFile = Path.ChangeExtension(strFile, "xlsx"); //} //foreach (string myfile in filePaths) //{ // filename = Path.ChangeExtension(myfile, ".txt"); // System.IO.File.Move(myfile, filename); //} ////------------------ Log newLog = new Log(); newLog.id = Guid.NewGuid(); int added = 0; int deleted = 0; int updated = 0; int errors = 0; int warnings = 0; string result = ""; int logg = 0; string name = ""; try { var excel = new ExcelQueryFactory(); string[] ex_names = MvcApplication.Config("excel_name").Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); //insert all employees from excel to temp list<> List <string> excel_emp_id = new List <string>(); for (int ex_name = 0; ex_name < ex_names.Length; ex_name++) { excel.FileName = ex_names[ex_name]; //employees from excel var result_employees = from c in excel.WorksheetNoHeader(0) select c; List <Employee> employees = new List <Employee>(); UpdateJobs(); UpdateDepartments(); //Dictionary Dictionary <string, long> dep_dict = new Dictionary <string, long>(); //existing Department from db List <Department> existing_deps = (List <Department>)GetSession.QueryOver <Department>().List(); foreach (Department dep in existing_deps) { dep_dict.Add(dep.Name, dep.Id); } //get all employees to dictinary Dictionary <string, long> emps_dict = new Dictionary <string, long>(); Dictionary <string, long> job_dict = new Dictionary <string, long>(); //existing Jobs from db List <JobTitle> existing_jobs = (List <JobTitle>)GetSession.QueryOver <JobTitle>().List(); foreach (JobTitle job in existing_jobs) { job_dict.Add(job.Name, job.Id); } Dictionary <string, string> users_managers = new Dictionary <string, string>(); //result_employees -> employees from excel int i = 0; foreach (var employee in result_employees) { //check for must feilds if (!string.IsNullOrEmpty(employee[1].ToString().Trim()) && !string.IsNullOrEmpty(employee[2].ToString().Trim()) && !string.IsNullOrEmpty(employee[13].ToString().Trim()) && !string.IsNullOrEmpty(employee[0].ToString().Trim())) { logg++; name = employee[0]; if (i > 0 && !string.IsNullOrEmpty(employee[0].ToString().Trim())) { //check for wanted feilds if (string.IsNullOrEmpty(employee[5].ToString().Trim()) || string.IsNullOrEmpty(employee[7].ToString().Trim())) { newLog.WarningLines = newLog.WarningLines + (i + 1) + ","; warnings++; } excel_emp_id.Add(employee[0].ToString().Trim()); if (employee[5] != "") { users_managers.Add(employee[0], employee[5]); } //if employee exists in DB if (GetSession.Get <Employee>(Convert.ToInt64(employee[0].ToString().Trim())) == null) { //add new employee string sBirthDate = employee[7].ToString().Trim() ?? ""; //string username = employee[9].ToString().Trim() == "" ? // "New User" : employee[9].ToString().Trim().Substring(0, employee[9].ToString().Trim().ToString().IndexOf('@')); string userName = employee[0].ToString().Trim(); EmployeeFormModel model = new EmployeeFormModel() { Id = Convert.ToInt64(employee[0].ToString().Trim()), Password = employee[0].ToString().Trim(), LastName = employee[2].ToString().Trim(), FirstName = employee[1].ToString().Trim(), Email = string.IsNullOrEmpty(employee[9].ToString().Trim()) ? "*****@*****.**" : employee[9].ToString().Trim(), Phone = employee[10].ToString().Trim(), Picture = employee[0].ToString().Trim() + ".jpg", Mobile = employee[11].ToString().Trim(), //Manager = GetSession.Get<Employee>(Convert.ToInt64(employee[5].ToString().Trim())), Range = employee[12].ToString().Trim(), BDay = (employee[7].ToString().Trim() != "") ? Convert.ToDateTime(sBirthDate) : DateTime.Now, IsActive = Convert.ToBoolean(Convert.ToInt32(employee[13].ToString().Trim())), JbTitle = GetSession.Get <JobTitle>(job_dict.FirstOrDefault(x => x.Key == employee[8].ToString().Trim()).Value), Department = GetSession.Get <Department>(dep_dict.FirstOrDefault(x => x.Key == employee[4].ToString().Trim()).Value), Username = userName }; var item = Mapper.Map <EmployeeFormModel, Employee>(model); GetSession.Save(item); added++; // string s = job_dict.FirstOrDefault(employee[3].ToString().Trim()).Key; } else { //update employee var item = GetSession.Get <Employee>(Convert.ToInt64(employee[0].ToString().Trim())); var model = Mapper.Map <Employee, EmployeeFormModel>(item); string sBirthDate = employee[7].ToString().Trim().ToString(); string userName = employee[0].ToString().Trim(); model.Password = employee[0].ToString().Trim(); model.LastName = employee[2].ToString().Trim(); model.FirstName = employee[1].ToString().Trim(); model.Email = string.IsNullOrEmpty(employee[9].ToString().Trim()) ? "*****@*****.**" : employee[9].ToString().Trim(); model.Phone = employee[10].ToString().Trim(); model.Mobile = employee[11].ToString().Trim(); model.Picture = employee[0].ToString().Trim() + ".jpg"; model.Range = employee[12].ToString().Trim(); //model.Manager = GetSession.Get<Employee>(Convert.ToInt64(employee[5].ToString().Trim())); model.IsActive = Convert.ToBoolean(Convert.ToInt32(employee[13].ToString().Trim())); model.BDay = (employee[7].ToString().Trim() != "") ? Convert.ToDateTime(sBirthDate) : DateTime.Now; model.JbTitle = GetSession.Get <JobTitle>(job_dict.FirstOrDefault(x => x.Key == employee[8].ToString().Trim()).Value); model.Department = GetSession.Get <Department>(dep_dict.FirstOrDefault(x => x.Key == employee[4].ToString().Trim()).Value); //model.Username = employee[9].ToString().Trim() == "" ? "" : employee[9].ToString().Trim().ToString().Substring(0, employee[9].ToString().Trim().ToString().IndexOf('@')); model.Username = userName; Mapper.Map <EmployeeFormModel, Employee>(model, item); GetSession.Update(item); updated++; } } i++; } else { newLog.ErrorLines = newLog.ErrorLines + (i + 1) + ","; errors++; i++; } } //TODO //update managers //UpdateManagers(users_managers); } // bring all existing employees List <Employee> current_employees = (List <Employee>)GetSession.QueryOver <Employee>().List(); foreach (Employee curr_emp in current_employees) { // if employee nof found in excel > disactivate this employee if (!excel_emp_id.Contains(curr_emp.Id.ToString())) { if (curr_emp.Username != MvcApplication.Config("admin.Username")) { var item = GetSession.Get <Employee>(curr_emp.Id); var model = Mapper.Map <Employee, EmployeeFormModel>(item); model.IsActive = false; Mapper.Map <EmployeeFormModel, Employee>(model, item); GetSession.Update(item); deleted++; } } #region 1 //if (curr_emp.Username == MvcApplication.Config("admin.Username")) //{ // var item = GetSession.Get<Employee>(curr_emp.Id); // var model = Mapper.Map<Employee, EmployeeFormModel>(item); // model.Username = "******"; // model.IsAdmin = true; // model.IsActive = true; // Mapper.Map<EmployeeFormModel, Employee>(model, item); // GetSession.Update(item); //} #endregion } } catch (Exception ex) { return(Content(ex.Data + ">>>>>" + ex.InnerException + ">>>>>" + ex.Message + " >>>>>>>> line" + logg + "name =" + name)); } result = string.Format("<h3>Update Results</h3><p>New : {0} </p><p>Processed : {1} </p><p>Deleted {2}</p><p>Errors {3}</p><p>Warnings {4}</p>", added, updated, deleted, errors, warnings); newLog.Logdate = DateTime.Now; newLog.UpdatedCount = updated; newLog.NewEmps = added.ToString(); GetSession.Save(newLog); TempData["warnings"] = newLog.WarningLines; return(RedirectToAction("ProssesResult", new { added = added, updated = updated, deleted = deleted, errors = errors, warningsL = newLog.WarningLines, warnings = warnings })); //return Content(result, "text/html"); }