public async Task <ActionResult> Edit([Bind(Include = "ID_Zay,Sotr_ID,Qwe_ID,otvet")] ZayavkaNaSobes zayavkaNaSobes) { if ((bool)Session["Manip_Tests"] == true && Session["Manip_Tests"] != null) { //Если валидация прошла успешно if (ModelState.IsValid) { //Изменение данных db.Entry(zayavkaNaSobes).State = EntityState.Modified; //Сохранение await db.SaveChangesAsync(); return(RedirectToAction("Index")); } //Список вопросов ViewBag.Qwe_ID = new SelectList(db.Questions, "ID_Quest", "Quest_Naim", zayavkaNaSobes.Qwe_ID); //Список соискателей ViewBag.Sotr_ID = new SelectList(db.Sotrs, "ID_Sotr", "Surname_Sot", zayavkaNaSobes.Sotr_ID); return(View(zayavkaNaSobes)); } else { return(Redirect("/Error/NotRight")); } }
public async Task <ActionResult> Create([Bind(Include = "ID_Pos_Res,Sotr_ID,Positions_ID,Rates_ID")] Posit_Responsibilities posit_Responsibilities) { if ((bool)Session["Manip_Sotrs"] == true && Session["Manip_Sotrs"] != null) { //Если валидация успешно прошла if (ModelState.IsValid) { //Добавление данных db.Posit_Responsibilities.Add(posit_Responsibilities); //Сохранение await db.SaveChangesAsync(); return(Redirect(Session["perehod"].ToString())); } //Список должностей ViewBag.Positions_ID = new SelectList(db.Positions.Where(p => p.Vak_Mest > 0), "ID_Positions", "Naim_Posit", posit_Responsibilities.Positions_ID); //Список ставок ViewBag.Rates_ID = new SelectList(db.Rates, "ID_Rate", "Rate", posit_Responsibilities.Rates_ID); string constr = ConfigurationManager.ConnectionStrings["PersonalContext"].ToString(); SqlConnection _con = new SqlConnection(constr); //Поиск сотрудников, которым не назначены должностные инструкции SqlDataAdapter _da = new SqlDataAdapter("SELECT ID_Sotr, Surname_Sot + ' ' + Name_Sot + ' ' + Petronumic_Sot + ' (' + Login_Acc + ')' as FIO FROM Sotrs LEFT JOIN Posit_Responsibilities ON Sotrs.ID_Sotr=Posit_Responsibilities.Sotr_ID WHERE Guest = 'false' and [fired] = 'false' and Posit_Responsibilities.Sotr_ID IS NULL", constr); DataTable _dt = new DataTable(); _da.Fill(_dt); //Список сотрудников ViewBag.Sotr_ID = ToSelectList(_dt, "ID_Sotr", "FIO", posit_Responsibilities.Sotr_ID); return(View(posit_Responsibilities)); } else { return(Redirect("/Error/NotRight")); } }
public async Task <ActionResult> Edit([Bind(Include = "Login,Password,Password_Shifr,Role_ID,Block,Logical_Delete")] Accounts accounts) { if ((bool)Session["Manip_Roles"] == true && Session["Manip_Roles"] != null) { //Если валидация прошла if (ModelState.IsValid) { //Зафиксировать изменения db.Entry(accounts).State = EntityState.Modified; //Сохранить данные await db.SaveChangesAsync(); //Показать страницу со всеми данными return(RedirectToAction("Index")); } //Список прав доступа ViewBag.Role_ID = new SelectList(db.Roles, "ID_Role", "Role_Naim", accounts.Role_ID); //Вернуть данные для корректировки return(View(accounts)); } else { return(Redirect("/Error/NotRight")); } }
public async Task <ActionResult> Create([Bind(Include = "ID_Schedule,Day_ID,Vremya_Start,Vremya_End,Break_time,Break_Start,Break_End,Sotr_ID, Vih")] Work_Schedule work_Schedule, int[] deleteInputs, int[] deleteInputs2) { if ((bool)Session["Manip_Sotrs"] == true && Session["Manip_Sotrs"] != null) { //Если валидация пройдена успешно if (ModelState.IsValid) { //Добавлене рабочих дней if (deleteInputs != null && deleteInputs.Length > 0) { for (int i = 0; i < deleteInputs.Length; i++) { work_Schedule.Day_ID = deleteInputs[i]; //Добавление db.Work_Schedule.Add(work_Schedule); //Сохранение в БД await db.SaveChangesAsync(); } if (deleteInputs2 != null && deleteInputs2.Length > 0) { //Добавление выходных дней for (int i = 0; i < deleteInputs2.Length; i++) { work_Schedule.Day_ID = deleteInputs2[i]; work_Schedule.Break_End = ""; work_Schedule.Break_Start = ""; work_Schedule.Break_time = ""; work_Schedule.Vih = true; work_Schedule.Vremya_End = ""; work_Schedule.Vremya_Start = ""; //Добавление данных db.Work_Schedule.Add(work_Schedule); //Сохранение await db.SaveChangesAsync(); } } return(Redirect(Session["perehod"].ToString())); } } //Список дней недели ViewBag.Day_ID = new SelectList(db.DaysOfWeek, "ID_Day", "Naim_Day", work_Schedule.Day_ID); //Поиск сотрудников, которым не назначен график работы string constr = ConfigurationManager.ConnectionStrings["PersonalContext"].ToString(); SqlConnection _con = new SqlConnection(constr); SqlDataAdapter _da = new SqlDataAdapter("SELECT ID_Sotr, Surname_Sot + ' ' + Name_Sot + ' ' + Petronumic_Sot + ' (' + Login_Acc + ')' as FIO FROM Sotrs LEFT JOIN Work_Schedule ON Sotrs.ID_Sotr=Work_Schedule.Sotr_ID WHERE Guest = 'false' and [fired] = 'false' and Work_Schedule.Sotr_ID IS NULL", constr); DataTable _dt = new DataTable(); _da.Fill(_dt); //Список сотрудников ViewBag.Sotr_ID = ToSelectList(_dt, "ID_Sotr", "FIO", work_Schedule.Sotr_ID); ViewBag.item = db.DaysOfWeek; return(View(work_Schedule)); } else { return(Redirect("/Error/NotRight")); } }
public async Task <ActionResult> Create([Bind(Include = "ID,LastName,FirstName,MiddleName")] Personal personal) { if (ModelState.IsValid) { db.Personal.Add(personal); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(personal)); }
public async Task Post([FromBody] FundAllocation value) { using (PersonalContext pc = new PersonalContext()) { FundAllocation fa = (from p in pc.FundAllocation where p.Symbol == value.Symbol select p).FirstOrDefault(); if (fa != null) { resetFA(ref fa, value); pc.Update(fa); } else { fa = new FundAllocation(); resetFA(ref fa, value); pc.FundAllocation.Add(fa); } try { await pc.SaveChangesAsync(); } catch (Exception ex) { string s = ex.Message; } } }
public async Task <ActionResult> DeleteConfirmedLog(int id) { if ((bool)Session["Manip_Sotrs"] == true && Session["Manip_Sotrs"] != null) { //Осуществление логического удаления Departments pos = await db.Departments.FindAsync(id); pos.Logical_Delete = true; db.Entry(pos).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } else { return(Redirect("/Error/NotRight")); } }
public async Task <ActionResult> DeleteConfirmed(int id) { if ((bool)Session["Manip_Sotrs"] == true && Session["Manip_Sotrs"] != null) { Sotrs sotrs = await db.Sotrs.FindAsync(id); //Удаление db.Sotrs.Remove(sotrs); //Сохранение await db.SaveChangesAsync(); return(RedirectToAction("Index")); } else { return(Redirect("/Error/NotRight")); } }
public async Task <ActionResult> DeleteConfirmedLog(int id) { if ((bool)Session["Manip_Sotrs"] == true && Session["Manip_Sotrs"] != null) { Positions pos = await db.Positions.FindAsync(id); //Логическое удаление pos.Logical_Delete = true; //изменение данных db.Entry(pos).State = EntityState.Modified; //Сохранение await db.SaveChangesAsync(); return(RedirectToAction("Index")); } else { return(Redirect("/Error/NotRight")); } }
public async Task <PersonDto> Handle(CreatePersonCommand request, CancellationToken cancellationToken) { await _validator.HandleValidation(request.PersonRequest); var person = request.PersonRequest.ToPerson(); var result = await _context.Persons.AddAsync(person); await _context.SaveChangesAsync(); return(result.Entity.ToPersonProtobuf()); }
public async Task <ActionResult> Create([Bind(Include = "ID_Quest,Quest_Naim")] Questions questions) { if ((bool)Session["Manip_Tests"] == true && Session["Manip_Tests"] != null) { //если валидация пройдена успешно if (ModelState.IsValid) { //Добавление данных db.Questions.Add(questions); //Сохранение await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(questions)); } else { return(Redirect("/Error/NotRight")); } }
public async Task <ActionResult> Create([Bind(Include = "ID_Role,Role_Naim,Manip_Roles,Manip_Sotrs,Manip_Department,Buh_Ych,Logical_Delete")] Roles roles) { if ((bool)Session["Manip_Roles"] == true && Session["Manip_Roles"] != null) { //если валидация пройдена успешно if (ModelState.IsValid) { //Добавление данных db.Roles.Add(roles); //Сохранение await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(roles)); } else { return(Redirect("/Error/NotRight")); } }
public async Task <IActionResult> Create(string Content) { PersonalPost personalPost = new PersonalPost(); personalPost.Content = Content; if (ModelState.IsValid) { personalPost.Id = Guid.NewGuid(); List <IFormFile> images = Request.Form.Files.Where(f => f.Name == "images[]").ToList(); string[] imgNameList = _UploadImages(images, personalPost.Id.ToString()); personalPost.ImageUrls = (imgNameList != null) ? string.Join(";", imgNameList) : null; personalPost.InsertDate = DateTime.Now; personalPost.LastUpdated = DateTime.Now; personalPost.UserId = _userManager.GetUserId(User); _context.Add(personalPost); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(personalPost)); }
public async Task <ActionResult> Create([Bind(Include = "ID_Pass,S_Pas,N_Pas,Sotr_ID")] Pass_Dannie pass_Dannie) { if ((bool)Session["Manip_Sotrs"] == true && Session["Manip_Sotrs"] != null) { //Если валидация прошла успешно if (ModelState.IsValid) { //Добавление данных db.Pass_Dannie.Add(new Pass_Dannie { Sotr_ID = pass_Dannie.Sotr_ID, N_Pas = Shifrovanie.Encryption(pass_Dannie.N_Pas), S_Pas = Shifrovanie.Encryption(pass_Dannie.S_Pas) }); //Сохранение await db.SaveChangesAsync(); //Обновление списка пасортных данных у всех пользователей EmployeesHub.BroadcastData(); return(RedirectToAction("Index")); } //Список сотрудников string constr = ConfigurationManager.ConnectionStrings["PersonalContext"].ToString(); SqlConnection _con = new SqlConnection(constr); //Поиск сотрудников, которым не назначены должностные инструкции SqlDataAdapter _da = new SqlDataAdapter("SELECT ID_Sotr, Surname_Sot + ' ' + Name_Sot + ' ' + Petronumic_Sot + ' (' + Login_Acc + ')' as FIO FROM Sotrs LEFT JOIN Pass_Dannie ON Sotrs.ID_Sotr=Pass_Dannie.Sotr_ID WHERE Guest = 'false' and [fired] = 'false' and Pass_Dannie.Sotr_ID IS NULL", constr); DataTable _dt = new DataTable(); _da.Fill(_dt); //Список сотрудников ViewBag.Sotr_ID = ToSelectList(_dt, "ID_Sotr", "FIO", pass_Dannie.Sotr_ID); return(View(pass_Dannie)); } else { return(Redirect("/Error/NotRight")); } }
public async Task <ActionResult> Edit([Bind(Include = "ID_St,Name_St")] status_isp_sroka status_isp_sroka) { if ((bool)Session["Manip_Sotrs"] == true && Session["Manip_Sotrs"] != null) { //Если валидация прошла успешно if (ModelState.IsValid) { //Изменение данных db.Entry(status_isp_sroka).State = EntityState.Modified; //Сохранение await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(status_isp_sroka)); } else { return(Redirect("/Error/NotRight")); } }
public async Task <ActionResult> Edit(Steps steps) { if ((bool)Session["Manip_Roles"] == true && Session["Manip_Roles"] != null) { //если валидация пройдена успешно if (ModelState.IsValid) { //Изменение данных db.Entry(steps).State = EntityState.Modified; //сохранение await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.Sotr_ID = new SelectList(db.Sotrs, "ID_Sotr", "Surname_Sot", steps.Sotr_ID); return(View(steps)); } else { return(Redirect("/Error/NotRight")); } }
public async Task <ActionResult> Create([Bind(Include = "ID_Isp,Pos_Res_ID,Date_Start,Date_Finish,Status_ID,itog")] Isp_Sroki isp_Sroki) { if ((bool)Session["Manip_Sotrs"] == true && Session["Manip_Sotrs"] != null) { //Если валидация прошла успешно if (ModelState.IsValid) { //Добавление испытательного срока db.Isp_Sroki.Add(isp_Sroki); //Сохранение await db.SaveChangesAsync(); SqlCommand command = new SqlCommand("", Program.SqlConnection); //Ведутся ли этапы принятия command.CommandText = "select count(*) from Steps join Sotrs on Steps.Sotr_ID = ID_Sotr join Posit_Responsibilities on Posit_Responsibilities.Sotr_ID = ID_Sotr where ID_Pos_Res = " + isp_Sroki.Pos_Res_ID; Program.SqlConnection.Open(); //выполнение запроса int?step_count = (int)command.ExecuteScalar(); //Получение ключа сотрудника command.CommandText = "select ID_Sotr from Sotrs join Posit_Responsibilities on Posit_Responsibilities.Sotr_ID = ID_Sotr where ID_Pos_Res = " + isp_Sroki.Pos_Res_ID; //выполнение команды int?idst = (int)command.ExecuteScalar(); Program.SqlConnection.Close(); if (isp_Sroki.Status_ID != 1) { if (step_count != null && step_count != 0) { //Изменение этапов принятия command.CommandText = "update [dbo].[Steps] set [Isp_Srok] = 'false' where Sotr_ID = " + idst; Program.SqlConnection.Open(); //Выполнение запроса command.ExecuteNonQuery(); Program.SqlConnection.Close(); } else { //Добавление этапов принятия command.CommandText = "Insert into dbo.Steps ([Sotr_ID],[Sobesedovanie],[Dolznost],[Grafik_Raboti],[Sbor_Documentov],[Isp_Srok],[Logical_Delete]) " + "values (" + idst + ", 0,0,0,0,0,0)"; Program.SqlConnection.Open(); //выполнения запроса command.ExecuteNonQuery(); Program.SqlConnection.Close(); } } else { if (step_count != null && step_count != 0) { //Изменение этапа принятия как пройденный испытательный срок command.CommandText = "update [dbo].[Steps] set [Isp_Srok] = 'true' where Sotr_ID = " + idst; Program.SqlConnection.Open(); //выполенение запроса command.ExecuteNonQuery(); Program.SqlConnection.Close(); } else { //Добавление испытательных сроков command.CommandText = "Insert into dbo.Steps ([Sotr_ID],[Sobesedovanie],[Dolznost],[Grafik_Raboti],[Sbor_Documentov],[Isp_Srok],[Logical_Delete]) " + "values (" + idst + ", 0,0,0,0,1,0)"; Program.SqlConnection.Open(); //выполнение запроса command.ExecuteNonQuery(); Program.SqlConnection.Close(); } } return(Redirect(Session["perehod"].ToString())); } else { //Строка подключения string constr = ConfigurationManager.ConnectionStrings["PersonalContext"].ToString(); SqlConnection _con = new SqlConnection(constr); //Добавление запроса SqlDataAdapter _da = new SqlDataAdapter("SELECT ID_Pos_Res, dbo.Sotrs.Surname_Sot + ' ' + dbo.Sotrs.Name_Sot + ' ' + dbo.Sotrs.Petronumic_Sot + ' (' + Naim_Posit + ')' as 'FIO' FROM dbo.Posit_Responsibilities JOIN dbo.Sotrs ON dbo.Posit_Responsibilities.Sotr_ID = dbo.Sotrs.ID_Sotr JOIN dbo.Positions ON dbo.Posit_Responsibilities.Positions_ID = dbo.Positions.ID_Positions where fired = 'false'", constr); DataTable _dt = new DataTable(); _da.Fill(_dt); //Список штатного состава ViewBag.Pos_Res_ID = ToSelectList(_dt, "ID_Pos_Res", "FIO", isp_Sroki.Pos_Res_ID); //Список статусов ViewBag.Status_ID = new SelectList(db.status_isp_sroka, "ID_St", "Name_St", isp_Sroki.Status_ID); return(View(isp_Sroki)); } } else { return(Redirect("/Error/NotRight")); } }