public ActionResult HesapEkle(FormCollection frm) { Hesaplar hesap = new Hesaplar(); int sayac = 1001; if (Session["UserTc"] == null && Session["UserAdSoyad"] == null) { return(RedirectToAction("Index")); } else { string tc = Session["UserTc"].ToString(); List <Hesaplar> Hesaplar = db.Hesaplar.Where(x => x.MusteriTc == tc).ToList(); if (Hesaplar.Count == 0) { String hesapNo = Session["HesapNo"].ToString(); hesap.HesapNo = hesapNo; hesap.EkNumara = sayac; } else { foreach (var item in Hesaplar) { sayac++; String hesapNo = Session["HesapNo"].ToString(); hesap.HesapNo = hesapNo; hesap.EkNumara = sayac; } } hesap.MusteriTc = Session["UserTc"].ToString(); hesap.Bakiye = Convert.ToDecimal(frm["bakiye"]); hesap.HesapDurum = true; db.Hesaplar.Add(hesap); db.SaveChanges(); var hesap2 = db.Hesaplar.Where(x => x.MusteriTc == tc).FirstOrDefault(); Session["HesapNoTamami"] = hesap2.HesapNo + "-" + sayac; frm.Clear(); return(RedirectToAction("HesapIslemleri")); } }
public ActionResult GuardarDiagnostico(FormCollection prmFormulario) { //(Convert.ToBoolean(prmFormulario[""])) if (((Convert.ToBoolean(prmFormulario["Fiebre"].Split(',')[0]) || (Convert.ToBoolean(prmFormulario["Respirar"].Split(',')[0])) || (Convert.ToBoolean(prmFormulario["Garganta"].Split(',')[0])) || (Convert.ToBoolean(prmFormulario["Olfato"].Split(',')[0])) || (Convert.ToBoolean(prmFormulario["Olfato"].Split(',')[0])) || (Convert.ToBoolean(prmFormulario["Tos"].Split(',')[0])) || (Convert.ToBoolean(prmFormulario["Fatiga"].Split(',')[0]))) == false) && (Convert.ToBoolean(prmFormulario["Respuesta"]) == false)) { ViewBag.MostrarFormulario = true; ViewBag.Diagnostico = false; ModelState.Clear(); Asistente prmAsistente = new Asistente(); return(View("Index", prmAsistente)); } else { prmFormulario.Clear(); Asistente datos = new Asistente(); ViewBag.MostrarFormulario = false; ViewBag.Diagnostico = true; ViewBag.MostrarModal = true; return(View("Index", datos)); } }
public void OrganizationTest() { FormCollection collection = new FormCollection(); ViewResult result; RedirectToRouteResult redirectToRouteResult; OrganizationController organizationController = Base.GetController <OrganizationController>(); PartialViewResult partialViewResult = organizationController.Edit(null); List <ITariff> tariffs = partialViewResult.ViewData.Get <List <ITariff> >("tariffs"); Assert.IsNotNull(tariffs); ITariff freeTariff = tariffs.Single(x => x.IsFree()); Assert.IsNotNull(freeTariff); Main.Registation(Email0); // создали тестовую организацию collection.Clear(); organizationController = Base.GetController <OrganizationController>(); collection.Add("Name", "test"); collection.Add("TariffId", freeTariff.Id.ToString()); partialViewResult = organizationController.Edit(null, collection); IOrganization organization = ((List <EmployeeSettings>)partialViewResult.Model).Single().Organization; Assert.IsNotNull(organization); int organizationId = organization.Id; #region Приглашения InviteController inviteController = Base.GetController <InviteController>(); // через мыло незареганного collection.Clear(); collection.Add("Email", Email3); inviteController.NewInvite(organizationId, collection); List <IUsersInvite> invites = inviteController.Utility.Invites.GetInvites(organizationId); IUsersInvite invite = invites.FirstOrDefault(x => x.EMail.ToUpper() == Email3.ToUpper()); Assert.IsNotNull(invite); Main.Registation(Email3, out result, out redirectToRouteResult, invite.InviteCode); ViewResultBase resultBase = organizationController.EmployeeList(organizationId); EmployeeSettings emeil3User = (resultBase.Model as List <EmployeeSettings>).FirstOrDefault(x => x.User.EMail.ToUpper() == Email3.ToUpper()); Assert.IsNotNull(emeil3User); collection.Clear(); collection.Add("delete", "true"); organizationController.EmployeeEdit(organizationId, emeil3User.User.Id, collection); // через мыло зареганного inviteController.Dispose(); inviteController = Base.GetController <InviteController>(); collection.Clear(); collection.Add("Email", Email3); inviteController.NewInvite(organizationId, collection); invites = organizationController.Utility.Invites.GetInvites(organizationId); invite = invites.FirstOrDefault(x => x.EMail.ToUpper() == Email3.ToUpper()); Assert.IsNotNull(invite); Base.GetController <AdminController>().ClearCache(); resultBase = organizationController.EmployeeList(organizationId); emeil3User = (resultBase.Model as List <EmployeeSettings>).FirstOrDefault(x => x.User.EMail.ToUpper() == Email3.ToUpper()); Assert.IsNotNull(emeil3User); var userController = Base.GetController <UserController>(); userController.Login(null, Email3, Email3, true, null); inviteController.AcceptInvite(organizationId); emeil3User = (resultBase.Model as List <EmployeeSettings>).FirstOrDefault(x => x.User.EMail.ToUpper() == Email3.ToUpper()); Assert.IsTrue(emeil3User.Settings.UserRole == (int)EmployeeRole.Employee); // через ссылку незареганного пользователя userController.Dispose(); userController = Base.GetController <UserController>(); userController.SignOut(); redirectToRouteResult = (RedirectToRouteResult)userController.Invite(organization.InviteCode); Assert.IsTrue(redirectToRouteResult.RouteValues["action"].ToString() == "Register"); collection.Clear(); Main.Registation(Email4, out result, out redirectToRouteResult, organization.InviteCode); resultBase = inviteController.List(); var organizations = (IEnumerable <IOrganization>)resultBase.Model; IOrganization first = organizations.FirstOrDefault(); Assert.IsTrue(first != null && first.Id == organizationId); inviteController.AcceptInvite(first.Id); resultBase = organizationController.EmployeeList(organizationId); EmployeeSettings emeil4User = ((List <EmployeeSettings>)resultBase.Model).FirstOrDefault(x => x.User.EMail.ToUpper() == Email4.ToUpper()); Assert.IsNotNull(emeil4User); collection.Clear(); collection.Add("delete", "true"); organizationController.EmployeeEdit(organizationId, emeil4User.User.Id, collection); // через ссылку зареганного пользователя userController.Dispose(); userController = Base.GetController <UserController>(); redirectToRouteResult = (RedirectToRouteResult)userController.Invite(organization.InviteCode); Assert.IsTrue(redirectToRouteResult.RouteValues["action"].ToString() == "Index"); collection.Clear(); inviteController.Dispose(); inviteController = Base.GetController <InviteController>(); resultBase = inviteController.List(); organizations = (IEnumerable <IOrganization>)resultBase.Model; first = organizations.FirstOrDefault(); Assert.IsTrue(first != null && first.Id == organizationId); inviteController.AcceptInvite(first.Id); resultBase = organizationController.EmployeeList(organizationId); emeil4User = (resultBase.Model as List <EmployeeSettings>).FirstOrDefault(x => x.User.EMail.ToUpper() == Email4.ToUpper()); Assert.IsNotNull(emeil4User); #endregion #region Удаление userController.Dispose(); userController = Base.GetController <UserController>(); userController.Login(null, Email3, Email3, true, null); BoardsController boardsController = Base.GetController <BoardsController>(); collection.Clear(); collection.Add("name", "t1"); collection.Add("OrganizationId", organizationId.ToString()); boardsController.Create(collection); collection.Clear(); collection.Add("name", "t2"); collection.Add("OrganizationId", organizationId.ToString()); boardsController.Create(collection); collection.Clear(); organizationController = Base.GetController <OrganizationController>(); organizationController.Delete(organizationId); boardsController = Base.GetController <BoardsController>(); partialViewResult = boardsController.List(null); Assert.IsFalse((partialViewResult.Model as List <IBoard>).Single().OrganizationId.HasValue); // остается только личная доска #endregion }
public void MainTest() { ViewResult result; RedirectToRouteResult redirectToRouteResult; FormCollection collection = new FormCollection(); #region егистрация/Атовризация IUser user0 = Registation(Email0); IUser user2 = Registation(Email2, out result, out redirectToRouteResult, null); IUser user1 = Registation(Email1, out result, out redirectToRouteResult, null); #endregion #region Создание доски BoardsController boardsController = Base.GetController <BoardsController>(); collection.Clear(); collection.Add("name", "test"); collection.Add("description", "description"); redirectToRouteResult = (RedirectToRouteResult)boardsController.Create(collection); int boardId = redirectToRouteResult.RouteValues["Id"].To <int>(); var board = boardsController.Utility.Boards.Get(boardId); Assert.IsNotNull(board); #endregion #region Проверяем статусы TasksStatusesController tasksStatusesController = Base.GetController <TasksStatusesController>(); PartialViewResult resultBase = tasksStatusesController.List(boardId); IEnumerable <ITasksStatus> statuses = (IEnumerable <ITasksStatus>)resultBase.Model; Assert.AreEqual(statuses.First().Name, "Беклог"); tasksStatusesController = Base.GetController <TasksStatusesController>(); resultBase = tasksStatusesController.Edit(boardId, new TimezStatus { Name = "test", BoardId = boardId }); statuses = (IEnumerable <ITasksStatus>)resultBase.Model; Assert.AreEqual(statuses.ElementAt(statuses.Count() - 1).Name, "test"); #endregion #region проверяем задачи var user = boardsController.Utility.Users.Get(Email1); var boardStatusList = boardsController.Utility.Statuses.GetByBoard(board.Id); // получаем доску var boardData = (ViewResultBase)boardsController.Edit(boardId); Assert.IsInstanceOfType(boardData.Model, typeof(IBoard)); ProjectsController projectController = Base.GetController <ProjectsController>(); IEnumerable <IProject> projs = (IEnumerable <IProject>)projectController.List(boardId).Model; Assert.IsNotNull(projs); // получаем цвета доски var boardColor = (ViewResultBase)boardsController.EditColorList(boardId); Assert.IsInstanceOfType(boardColor.ViewData.Model, typeof(IEnumerable <IBoardsColor>)); IEnumerable <IBoardsColor> boardColors = boardColor.ViewData.Model as IEnumerable <IBoardsColor>; // Создание задачи collection.Clear(); collection["task-id"] = null; collection["task-statusid"] = boardStatusList[0].Id.ToString(); collection["task-userid"] = user.Id.ToString(); collection["task-name"] = "Тестовая задача"; collection["task-description"] = "Описание тестовой задачи"; collection["task-projectsid"] = projs.First().Id.ToString(); collection["task-colorid"] = boardColors.First().Id.ToString(CultureInfo.InvariantCulture); // проверяем создание KanbanController kanbanController = Base.GetController <KanbanController>(); ViewResultBase taskData = (ViewResultBase)kanbanController.TaskPopup(boardId, null, collection); ITask task = CheckTask(taskData); Assert.IsTrue(task.CreatorUserId == kanbanController.Utility.Authentication.UserId); // архивирование collection["task-name"] = "Тестовая задача2"; taskData = (ViewResultBase)kanbanController.TaskPopup(boardId, null, collection); ITask task2 = CheckTask(taskData); kanbanController.ToArchive(boardId, task2.Id); TasksController tasksController = Base.GetController <TasksController>(); taskData = tasksController.Details(boardId, task2.Id, true); Assert.IsTrue((taskData.Model as ITask).Id == task2.Id); Assert.IsTrue((bool)taskData.ViewData["isArchive"]); // обновляем задачу collection.Clear(); collection["task-id"] = task.Id.ToString(); ITasksStatus planningStatus = boardStatusList.First(x => x.PlanningRequired); collection["task-statusid"] = planningStatus.Id.ToString(); collection["task-userid"] = user.Id.ToString(); collection["task-name"] = "Тестовая задачаю. Обновление"; collection["task-description"] = "Описание тестовой задачи. Обновление"; collection["task-projectsid"] = projs.First().Id.ToString(); collection["task-colorid"] = boardColors.ToList()[1].Id.ToString(); kanbanController.Dispose(); kanbanController = Base.GetController <KanbanController>(); var json = (JsonResult)kanbanController.TaskPopup(boardId, task.Id, collection); Assert.IsTrue((json.Data as JsonMessage).Message == new PlanningTimeRequered(planningStatus).Message); // проверяем изменение цвета kanbanController = Base.GetController <KanbanController>(); var color = kanbanController.SetColor(task.Id, boardColors.ToList()[0].Id, boardId); Assert.AreNotEqual(color, ""); // проверям установку времени kanbanController = Base.GetController <KanbanController>(); collection.Clear(); collection["task-forsed-count"] = "true"; collection["task-forsed-time"] = "false"; #pragma warning disable 168 JsonResult planningTime = (JsonResult)kanbanController.SetPlanningTime(boardId, task.Id, 180, task.TaskStatusId, collection); #pragma warning restore 168 // проверяем обновление статуса kanbanController = Base.GetController <KanbanController>(); collection.Clear(); collection["task-forsed-count"] = "true"; collection["task-forsed-time"] = "false"; kanbanController.UpdateStatus(boardId, task.Id, boardStatusList[0].Id, collection); // проверяем исполнителя kanbanController = Base.GetController <KanbanController>(); user = kanbanController.Utility.Users.Get(Email2); kanbanController.SetExecutor(task.BoardId, task.Id, user.Id); // проверяем проект // сначала создадим проект projectController.Dispose(); projectController = Base.GetController <ProjectsController>(); collection.Clear(); string projectName = "тестовый проект " + DateTime.Now.Ticks.ToString(); collection["Name"] = projectName; var projectData = (ViewResultBase)projectController.Edit(boardId, null, collection); // проверяем создание проекта Assert.IsInstanceOfType(projectData.ViewData.Model, typeof(IEnumerable <IProject>)); var projects = projectData.ViewData.Model as IEnumerable <IProject>; var project = projects.SingleOrDefault(p => p.Name == projectName); Assert.IsNotNull(project); // изменяем проект kanbanController = Base.GetController <KanbanController>(); kanbanController.SetProject(task.BoardId, task.Id, project.Id); // переназначение ParticipantController participantController = Base.GetController <ParticipantController>(); collection.Clear(); collection["participant-id"] = user1.Id.ToString(); participantController.Tasks(boardId, user0.Id, collection); collection["participant-id"] = user2.Id.ToString(); participantController.Tasks(boardId, user0.Id, collection); // удаление kanbanController = Base.GetController <KanbanController>(); kanbanController.DeleteTask(task2.Id, task2.BoardId); kanbanController.DeleteTask(task.Id, task.BoardId); // проверяем удаление kanbanController = Base.GetController <KanbanController>(); kanbanController.Index(boardId); kanbanController = Base.GetController <KanbanController>(); collection.Clear(); PartialViewResult kanban = kanbanController.Kanban(boardId, collection); Assert.IsInstanceOfType(kanban.ViewData["Tasks"], typeof(IEnumerable <ITask>)); IEnumerable <ITask> boardTasks = kanban.ViewData["Tasks"] as IEnumerable <ITask>; ITask deletedTask = boardTasks.FirstOrDefault(t => t.Id == task.Id); Assert.IsNull(deletedTask); // Проверка попадания в журнал ошибок и предупреждений var logController = Base.GetController <LogController>(); var logData = (ViewResultBase)logController.Items(boardId, null); Assert.IsInstanceOfType(logData.ViewData.Model, typeof(IEnumerable <IEventHistory>)); var logs = logData.ViewData.Model as IEnumerable <IEventHistory>; var boardEvents = logs.Where(p => p.BoardId == boardId); Assert.AreNotEqual(boardEvents.Count(), 0); Assert.AreNotEqual(boardEvents.Count(e => (e.EventType & EventType.CreateTask) == EventType.CreateTask), 0); Assert.AreNotEqual(boardEvents.Count(e => (e.EventType & EventType.Delete) == EventType.Delete), 0); Assert.AreNotEqual(boardEvents.Count(e => (e.EventType & EventType.Update) == EventType.Update), 0); Assert.AreNotEqual(boardEvents.Count(e => (e.EventType & EventType.TaskColorChanged) == EventType.TaskColorChanged), 0); Assert.AreNotEqual(boardEvents.Count(e => (e.EventType & EventType.TaskAssigned) == EventType.TaskAssigned), 0); Assert.AreNotEqual(boardEvents.Count(e => (e.EventType & EventType.ProjectChanged) == EventType.ProjectChanged), 0); Assert.AreNotEqual(boardEvents.Count(e => (e.EventType & EventType.PlaningTimeChanged) == EventType.PlaningTimeChanged), 0); #endregion #region Удаление досок boardsController.Dispose(); boardsController = Base.GetController <BoardsController>(); PartialViewResult partialResult = boardsController.List(null); Assert.IsInstanceOfType(partialResult.Model, typeof(List <IBoard>)); foreach (IBoard item in partialResult.Model as List <IBoard> ) { boardsController = Base.GetController <BoardsController>(); boardsController.Delete(item.Id); try { board = boardsController.Utility.Boards.Get(item.Id); Assert.IsNull(board); } catch (Exception ex) { Assert.IsInstanceOfType(ex, typeof(AccessDeniedException)); } } #endregion boardsController.Utility.Users.Delete(Email1); Assert.IsNull(boardsController.Utility.Users.Get(Email1)); }
/// <summary> /// Updating Assessment by Venture for old versions of Venture (new versions should use new function). /// </summary> /// <param name="json"></param> /// <returns>string - exception message if any.</returns> public static string UpdateAssessmentJSON(IFormsRepository formsRepo, string json) { string result = String.Empty; try { var dResults = fastJSON.JSON.Parse(json); Dictionary <string, Object> resDict = (Dictionary <string, Object>)dResults; List <Object> resList = (List <Object>)resDict[""]; List <Object> firstList = (List <Object>)resList[0]; int formStatus = Int32.Parse(firstList[4].ToString()); int formResultId = Int32.Parse(firstList[3].ToString()); Debug.WriteLine("Defws UpdateAssessmentJSON formResultId:" + firstList[3].ToString()); def_FormResults fr = formsRepo.GetFormResultById(formResultId); fr.formStatus = (byte)formStatus; fr.dateUpdated = DateTime.Parse(firstList[5].ToString()); SessionHelper.SessionForm = new SessionForm() { formId = fr.formId, formResultId = formResultId }; AccessLogging.InsertAccessLogRecord(formsRepo, formResultId, (int)AccessLogging.accessLogFunctions.IMPORT, "Imported assessment from Venture."); int sectionId = Int32.Parse(firstList[0].ToString()); def_Sections section = formsRepo.GetSectionById(sectionId); SessionHelper.SessionForm.sectionId = sectionId; FormCollection fc = new FormCollection(); List <Object> rspData = null; foreach (Object res in resList) { rspData = (List <Object>)res; int nextSectionId = Int32.Parse(rspData[0].ToString()); if (nextSectionId != sectionId) { // New section; save last section's form collection if (section == null) { Debug.WriteLine("Missing section " + sectionId + " on server."); sectionId = nextSectionId; continue; // If a section is missing, go to the next one but log error to console //throw new Exception("Missing section " + sectionId + " on server."); } //* * * OT 03/10/16 Switched to using AJBoggs\Def\Domain\UserData.SaveFormCollection.cs new UserData(formsRepo).FormResultsSaveSaveSectionItems(section, fc, formResultId); sectionId = nextSectionId; section = formsRepo.GetSectionById(sectionId); SessionHelper.SessionForm.sectionId = sectionId; fc.Clear(); } string identifier = rspData[2].ToString(); string value = String.Empty; if (rspData[1] != null) { value = rspData[1].ToString(); } fc.Add(identifier, value); } if (section != null) { //ResultsController r = new ResultsController(formsRepo); //* * * OT 03/10/16 Switched to using AJBoggs\Def\Domain\UserData.SaveFormCollection.cs new UserData(formsRepo).FormResultsSaveSaveSectionItems(section, fc, formResultId); } else { Debug.WriteLine("Missing section " + sectionId + " on server."); } formsRepo.SaveFormResults(fr); AccessLogging.InsertAccessLogRecord(formsRepo, fr.formResultId, (int)AccessLogging.accessLogFunctions.CHECK_IN, "Check in of assessment from Venture by " + SessionHelper.LoginInfo.LoginID); ReviewStatus.ChangeStatus(formsRepo, fr, ReviewStatus.CHECKED_IN, "Checked in from Venture by " + SessionHelper.LoginInfo.LoginID); ReviewStatus.AssessmentIsCompleted(formsRepo, fr); } catch (Exception excptn) { Debug.WriteLine("Defws UpdateAssessmentJSON exception:" + excptn.Message); result = excptn.Message; if ((excptn.InnerException != null) && (excptn.InnerException.Message != null)) { result = result + " " + excptn.InnerException.Message; } } return(result); }
public string processExcel(HttpPostedFileBase file) { int readData = 0; //data for service FormCollection formCollection = new FormCollection(); //process try { IWorkbook wb = new XSSFWorkbook(file.InputStream); ISheet sheet = wb.GetSheetAt(wb.ActiveSheetIndex); List <string> keys = new List <string> { "child-ch-name", "child-fname", "child-name", "child-birth", "child-gender", "child-class", "child-address", "fa-ch-name", "fa-fname", "fa-name", "fa-phone", "mo-ch-name", "mo-fname", "mo-name", "mo-phone" }; // int count = 0; IRow row; ICell cell; for (int rowIndex = 1; rowIndex <= sheet.LastRowNum; rowIndex++) { row = sheet.GetRow(rowIndex); for (int cellIndex = 0; cellIndex < row.LastCellNum; cellIndex++) { try { cell = row.GetCell(cellIndex); cell.SetCellType(CellType.String); formCollection.Set(keys[count], cell.StringCellValue); } catch (Exception) { formCollection.Set(keys[count], ""); } count++; } formCollection.Set("child-role", "4"); using (PersonService personService = new PersonService()) { Response res = personService.addPerson(formCollection); if (res.success) { readData++; } } //clear before add new record count = 0; formCollection.Clear(); } } catch (Exception e) { return("ERROR" + e.Message); } return("Processed " + readData + " records"); }