public AjaxModel<string> Post([FromBody] PatientModel model) { AjaxModel<string> ajax = new AjaxModel<string>() { Success = true, Message = PosMessage.PatientSaveSuccessful, Model = PosMessage.Blank }; try { PatientRepository.PatientSave(model); } catch(Exception exp) { ajax.Success = false; ajax.Message = exp.Message; } return ajax; }
public AjaxModel<PrintQueueModel> Get() { AjaxModel<PrintQueueModel> ajax = null; PrintQueueModel model = PosRepository.PrintQueueGet(); if (model == null) { ajax = new AjaxModel<PrintQueueModel>() { Success = false, Message = PosMessage.PrintQueueError, Model = null }; } else { ajax = new AjaxModel<PrintQueueModel>() { Success = true, Message = "", Model = model }; } return ajax; }
public AjaxModel<ProfileModel> Post([FromBody] LoginModel model) { AjaxModel<ProfileModel> ajax = null; ProfileModel profile = PosRepository.ProfileGet(model); if(profile == null) { ajax = new AjaxModel<ProfileModel>() { Success = false, Message = PosMessage.LoginError, Model = null }; } else { ajax = new AjaxModel<ProfileModel>() { Success = true, Message = "", Model = profile }; } return ajax; }
public AjaxModel<string> Post([FromUri] int type, [FromBody] NotesModel model) { PosConstants.NotesSaveType saveType = (PosConstants.NotesSaveType) type; AjaxModel<string> ajax = new AjaxModel<string>() { Success = true, Model = PosMessage.Blank }; try { ajax.Message = new NotesDomain().Save(saveType, model); } catch (Exception exp) { ajax.Success = false; ajax.Message = exp.Message; } return ajax; }
public AjaxModel<string> LastVisitDateUpdate() { AjaxModel<string> ajax = new AjaxModel<string>() { Success = true, Message = PosMessage.LastVisitDateUpdateSuccess, Model = null }; try { PosRepository.UpdateLastVisitDate(); } catch (Exception exp) { ajax.Success = false; ajax.Message = exp.Message; } return ajax; }
public AjaxModel<Dictionary<string, List<LookUpModel>>> Get() { AjaxModel<Dictionary<string, List<LookUpModel>>> ajax = null; List<LookUpModel> lookupList = PosRepository.LookUpGet(); if (lookupList == null) { ajax = new AjaxModel<Dictionary<string, List<LookUpModel>>>() { Success = false, Message = PosMessage.LookUpGetError, Model = null }; } else { var model = GetLookUpDictionary(lookupList); ajax = new AjaxModel<Dictionary<string, List<LookUpModel>>>() { Success = true, Message = "", Model = model }; } return ajax; }
public AjaxModel<PrintQueueModel> Post(PrintQueueItem item) { AjaxModel<PrintQueueModel> ajax = null; try { PosRepository.PrintQueueRemove(item); ajax = new AjaxModel<PrintQueueModel>() { Success = true, Message = PosMessage.PrintQueueDeleteSuccessful, Model = null }; } catch (Exception e) { ajax = new AjaxModel<PrintQueueModel>() { Success = false, Message = PosMessage.PrintQueueDeleteError + " - " + e.Message, Model = null }; } return ajax; }
public AjaxModel<string[]> Get(string userName) { AjaxModel<string[]> ajax = new AjaxModel<string[]>() { Success = true }; try { ajax.Model = PosRepository.AutoCorrectGet(userName); } catch (Exception exp) { ajax.Success = false; ajax.Message = exp.Message; ajax.Model = null; } return ajax; }
public AjaxModel<UserModel> Get(int id) { AjaxModel<UserModel> ajax = null; UserModel result = PosRepository.UserGet(id); if (result == null) { ajax = new AjaxModel<UserModel>() { Success = false, Message = PosMessage.UserInvalid, Model = null }; } else { ajax = new AjaxModel<UserModel>() { Success = true, Message = "", Model = result }; } return ajax; }
public AjaxModel<List<SearchResultModel>> Post([FromBody] string criteria) { AjaxModel<List<SearchResultModel>> ajax = null; List<SearchResultModel> result = PatientRepository.PatientSearch(criteria.Trim()); if (result.Count == 0) { ajax = new AjaxModel<List<SearchResultModel>>() { Success = false, Message = PosMessage.PatientSearchNoRecords, Model = null }; } else { ajax = new AjaxModel<List<SearchResultModel>>() { Success = true, Message = "", Model = result }; } return ajax; }
public AjaxModel<List<int>> GetPatientIds([FromBody] int patientUpdateCount) { AjaxModel<List<int>> ajax = new AjaxModel<List<int>>() { Success = true, Message = "", Model = null }; try { //System.Threading.Thread.Sleep(100); ajax.Model = PatientRepository.PatientGetAllIds(patientUpdateCount); } catch (Exception exp) { ajax.Success = false; ajax.Message = exp.Message; } return ajax; }
public AjaxModel<NotesViewModel> Get(string userName, int patientID, int? examID) { AjaxModel<NotesViewModel> ajax = new AjaxModel<NotesViewModel>() { Success = true }; try { ajax.Model = new NotesDomain().GetNotes(userName, patientID, examID); } catch (Exception exp) { ajax.Success = false; ajax.Message = exp.Message; ajax.Model = null; } return ajax; }
public AjaxModel<PatientModel> Get(int id) { AjaxModel<PatientModel> ajax = null; PatientModel result = PatientRepository.PatientGet(id, true); if(result == null) { ajax = new AjaxModel<PatientModel>() { Success = false, Message = PosMessage.PatientInvalid, Model = null }; } else { ajax = new AjaxModel<PatientModel>(){Success = true, Message = "", Model = result }; } return ajax; }
public AjaxModel<List<int>> UpdatePatientHistory([FromBody] int patientID) { AjaxModel<List<int>> ajax = new AjaxModel<List<int>>() { Success = true, Message = "", Model = null }; try { //System.Threading.Thread.Sleep(100); NotesDomain domain = new NotesDomain(); domain.PatientExamDataSave(patientID); } catch (Exception exp) { ajax.Success = false; ajax.Message = exp.Message; } return ajax; }
public AjaxModel<NotesViewModel> Get(int doctorUserID, int? examDefaultID) { AjaxModel<NotesViewModel> ajax = new AjaxModel<NotesViewModel>() { Success = true }; try { NotesDomain domain = new NotesDomain(); ajax.Model = domain.GetDefaultNotes(doctorUserID, examDefaultID); } catch (Exception exp) { ajax.Success = false; ajax.Message = exp.Message; ajax.Model = null; } return ajax; }
public AjaxModel<String> PostSaveLookUps(List<LookUpModel> lookupList) { AjaxModel<string> ajax = new AjaxModel<string>(); try { if (lookupList != null) { foreach (var lookupModel in lookupList) { if (lookupModel.IsNew) { PosRepository.AddLookUpModel(lookupModel); } else if (lookupModel.IsDeleted) { PosRepository.RemoveLookUpModel(lookupModel.LookUpID); } else { PosRepository.UpdateLookUpModel(lookupModel); } } ajax.Success = true; ajax.Message = PosMessage.LookupsSavedSuccessfully ; } } catch (Exception exp) { ajax.Success = false; ajax.Message = String.Format("Message {0} Error {1}" ,PosMessage.LookUpsSaveError , exp.Message) ; } return ajax; }
public ActionResult Partners_getItems() { var parameters = AjaxModel.GetParameters(HttpContext); var mng = new PartnersManager(); var rep = new CoreRepository(); var p = new DynamicParameters(); var specialization = mng.GetPartnersSpec(); List <int?> statusIDs = new List <int?>(); List <int?> specsIDs = new List <int?>(); if (parameters.filter != null && parameters.filter.Count > 0) { p.Add("text", parameters.filter.ContainsKey("text") ? parameters.filter["text"].ToString().Trim() : string.Empty); if (parameters.filter.ContainsKey("statusIDs")) { statusIDs = parameters.filter["statusIDs"].ToString() != string.Empty ? parameters.filter["statusIDs"].ToString().Split(',').Select(x => (int?)RDL.Convert.StrToInt(x.ToString(), 0)).ToList() : null; } if (parameters.filter.ContainsKey("specIDs")) { specsIDs = parameters.filter["specIDs"].ToString() != string.Empty ? parameters.filter["specIDs"].ToString().Split(',').Select(x => (int?)RDL.Convert.StrToInt(x, 0)).ToList() : null; } } string[] sorts = parameters.sort.Split(",".ToArray(), StringSplitOptions.RemoveEmptyEntries); string sort1 = sorts.Length > 0 ? sorts[0] : ""; string[] directions = parameters.direction.Split(",".ToArray(), StringSplitOptions.RemoveEmptyEntries); string direction1 = directions.Length > 0 ? directions[0] : ""; if (specsIDs != null) { p.Add("specsIDs", String.Join(",", specsIDs)); } else { p.Add("specsIDs", String.Join(",", string.Empty)); } if (statusIDs != null) { p.Add("statusIDs", String.Join(",", statusIDs)); } else { p.Add("statusIDs", String.Join(",", string.Empty)); } p.Add("sort1", sort1); p.Add("direction1", direction1); p.Add("page", parameters.page); p.Add("pageSize", parameters.pageSize); p.Add("total", dbType: DbType.Int32, direction: ParameterDirection.Output); var items = rep.GetSQLData <dynamic>("[GetPartners]", p, CommandType.StoredProcedure); var total = p.Get <object>("total"); var res = new List <object>(); foreach (var group in (items as List <dynamic>).GroupBy(x => x.partnerID)) { var partner = group.FirstOrDefault(); var specs = string.Empty; foreach (var item in specialization) { specs += string.Format("<input type='checkbox' class='specialization' " + (group.FirstOrDefault(x => (int)x.specsID == item.id) != null ? "checked": string.Empty) + " specID='" + item.id + "' id='spec" + item.id + "' /><label for='spec" + item.id + "'>{0}</label><br />", item.name); } res.Add(new { partnerID = group.Key, partner.fio, partner.statusName, partner.url, partner.desc, partner.experience, partner.technologies, partner.conditions, specs = specs }); } var json = JsonConvert.SerializeObject(new { items = res, total = res.Count }); return(Content(json, "application/json")); }
public ActionResult PartnersStatuses_getItems() { var parameters = AjaxModel.GetParameters(HttpContext); var mng = new PartnersManager(); var items = mng.GetPartnerStatuses(); var res = items.Select(item => new ps_statuses { id = item.id, name = item.name.Trim(), code = item.code.Trim(), color = item.color.Trim(), order = item.order }).AsQueryable(); var sorts = parameters.sort.Split(",".ToArray(), StringSplitOptions.RemoveEmptyEntries); var directions = parameters.direction.Split(",".ToArray(), StringSplitOptions.RemoveEmptyEntries); var sort1 = sorts.Length > 0 ? sorts[0] : ""; var direction1 = directions.Length > 0 ? directions[0] : ""; switch (sort1) { case "name": if (direction1 == "up") { res = res.OrderBy(x => x.name); } else { res = res.OrderByDescending(x => x.name); } break; case "code": if (direction1 == "up") { res = res.OrderBy(x => x.code); } else { res = res.OrderByDescending(x => x.code); } break; case "color": if (direction1 == "up") { res = res.OrderBy(x => x.color); } else { res = res.OrderByDescending(x => x.color); } break; case "order": if (direction1 == "up") { res = res.OrderBy(x => x.order); } else { res = res.OrderByDescending(x => x.order); } break; default: if (direction1 == "up") { res = res.OrderBy(x => x.name); } else { res = res.OrderByDescending(x => x.name); } break; } var total = res.Count(); var res2 = res.Skip(parameters.pageSize * (parameters.page - 1)).Take(parameters.pageSize).ToList(); return(Json(new { items = res2.Select(x => new { x.id, x.name, x.code, x.color, x.order }), total = items.Count }, JsonRequestBehavior.AllowGet)); }
public ActionResult StatisticImportExport_getItems() { var parameters = AjaxModel.GetParameters(HttpContext); var mng = new ImpManager(); DateTime createdMin = (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue; DateTime createdMax = (DateTime)System.Data.SqlTypes.SqlDateTime.MaxValue; var user = ""; var operationId = 0; var datatable = ""; var checkError = false; //--------------обработка фильтров-------------- if (parameters.filter != null && parameters.filter.Count > 0) { if (parameters.filter.ContainsKey("creat") && parameters.filter["creat"] != null) { var dates = parameters.filter["creat"].ToString() .Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries); if (dates.Length > 0) { createdMin = RDL.Convert.StrToDateTime(dates[0].Trim(), (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue); } if (dates.Length > 1) { createdMax = RDL.Convert.StrToDateTime(dates[1].Trim(), (DateTime)System.Data.SqlTypes.SqlDateTime.MaxValue); } } if (parameters.filter.ContainsKey("user") && parameters.filter["user"] != null) { var userId = RDL.Convert.StrToGuid(parameters.filter["user"].ToString(), Guid.Empty); var users = new CoreManager(); user = userId == Guid.Empty ? "" : users.GetUsers().First(i => i.UserId == userId).UserName; } if (parameters.filter.ContainsKey("oper") && parameters.filter["oper"] != null) { operationId = RDL.Convert.StrToInt(parameters.filter["oper"].ToString(), 0); } if (parameters.filter.ContainsKey("object") && parameters.filter["object"] != null) { datatable = parameters.filter["object"].ToString(); } if (parameters.filter.ContainsKey("checked") && parameters.filter["checked"] != null) { checkError = Convert.ToBoolean(parameters.filter["checked"].ToString()); } } var sorts = parameters.sort.Split(",".ToArray(), StringSplitOptions.RemoveEmptyEntries); var directions = parameters.direction.Split(",".ToArray(), StringSplitOptions.RemoveEmptyEntries); var sort1 = sorts.Length > 0 ? sorts[0] : ""; var direction1 = directions.Length > 0 ? directions[0] : ""; var rep = new ImpRepository(); var p = new DynamicParameters(); p.Add("user", user); p.Add("operationId", operationId); p.Add("datatable", datatable); p.Add("checkError", checkError); p.Add("createdMin", createdMin); p.Add("createdMax", createdMax); p.Add("sort1", sort1); p.Add("direction1", direction1); p.Add("page", parameters.page); p.Add("pageSize", parameters.pageSize); p.Add("total", dbType: DbType.Int32, direction: ParameterDirection.Output); var items = rep.GetSQLData <dynamic>("GetStatisticImportExport", p, CommandType.StoredProcedure); var total = p.Get <int>("total"); var json = JsonConvert.SerializeObject(new { items, total = total }); return(Content(json, "application/json")); }
public ActionResult MailsList_getItems() { var parameters = AjaxModel.GetParameters(HttpContext); var user = mng.GetUser(); string msg = ""; var items = mng.Mails.GetMails(out msg, user); if (parameters.filter != null && parameters.filter.Count > 0) { var text = parameters.filter.ContainsKey("text") ? parameters.filter["text"].ToString() : ""; if (text != "") { items = items.Where(x => x.fromSender != null && x.fromSender.Contains(text)).ToList(); } var delSysID = parameters.filter.ContainsKey("delSysID") ? RDL.Convert.StrToInt(parameters.filter["delSysID"].ToString(), 0) : 0; if (delSysID != 0) { items = items.Where(x => x.deliverySystemID == delSysID).ToList(); } List <int?> statusIDs = new List <int?>(); if (parameters.filter.ContainsKey("statusIDs")) { statusIDs = (parameters.filter["statusIDs"] as ArrayList).ToArray().Select(x => (int?)RDL.Convert.StrToInt(x.ToString(), 0)).ToList(); } if (statusIDs.Count != 0) { items = items.Where(x => statusIDs.Contains(x.mailStatusID)).ToList(); } } var sorts = parameters.sort.Split(",".ToArray(), StringSplitOptions.RemoveEmptyEntries); var directions = parameters.direction.Split(",".ToArray(), StringSplitOptions.RemoveEmptyEntries); var sort1 = sorts.Length > 0 ? sorts[0] : ""; var direction1 = directions.Length > 0 ? directions[0] : ""; switch (sort1) { case "number": if (direction1 == "up") { items = items.OrderBy(x => x.fromSender).ToList(); } else { items = items.OrderByDescending(x => x.fromSender).ToList(); } break; case "email": if (direction1 == "up") { items = items.OrderBy(x => x.date).ToList(); } else { items = items.OrderByDescending(x => x.date).ToList(); } break; case "sum": if (direction1 == "up") { items = items.OrderBy(x => x.toRecipient).ToList(); } else { items = items.OrderByDescending(x => x.toRecipient).ToList(); } break; default: if (direction1 == "up") { items = items.OrderBy(x => x.fromSender).ToList(); } else { items = items.OrderByDescending(x => x.fromSender).ToList(); } break; } var total = items.Count(); var res = items.Skip(parameters.pageSize * (parameters.page - 1)).Take(parameters.pageSize).ToList(); var json = JsonConvert.SerializeObject(new { items = res.Select(x => new { id = x.id, uniqueCode = x.uniqueCode, date = x.date.ToShortDateString(), fromSender = x.fromSender, toRecipient = x.toRecipient, description = x.description, trackNumber = x.trackNumber, backTrackNumber = x.backTrackNumber, backDateReceipt = x.backDateReceipt, delSystemsName = x.molchanov_deliverySystems.name, mailStatuses = x.molchanov_mailStatuses.name }), msg = msg, total = total }); return(Content(json, "application/json")); }
public ActionResult ProcessItem_getItems() { var parameters = AjaxModel.GetParameters(HttpContext); var mng = new ProcessManager(); var items = mng.GetProcessItems() .AsQueryable() .Skip(parameters.pageSize * (parameters.page - 1)) .Take(parameters.pageSize); // //var items = mng.GetSQLClients("GetCRMClients").AsQueryable(); var sortName = parameters.sort.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); var sortDirection = parameters.direction.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (sortName.Length > 0 & sortDirection.Length > 0) { for (int i = 0; i < sortName.Length; i++) { if (i > 0) { items = items.ThenByField(sortName[i], (sortDirection[0] == "up")); } else { items = items.OrderByField(sortName[i], (sortDirection[0] == "up")); } } } if (parameters.filter != null && parameters.filter.Count > 0) { if (parameters.filter.ContainsKey("name")) { if (!string.IsNullOrWhiteSpace(parameters.filter["name"].ToString())) { items = items.Where(x => x.name.Contains(parameters.filter["name"].ToString())); } } if (parameters.filter.ContainsKey("isFinish")) { if (parameters.filter["isFinish"].ToString() != "-1") { items = items.Where(x => x.isFinish == Convert.ToBoolean(RDL.Convert.StrToInt(parameters.filter["isFinish"].ToString(), 0))); } } if (parameters.filter.ContainsKey("roles")) { string[] statusIDs; statusIDs = (parameters.filter["roles"] as ArrayList).ToArray().Select(x => x.ToString()).ToArray(); if (statusIDs.Length != 0) { items = items.Where(x => SearchArrayPattern(statusIDs, x.roles.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))); } } if (parameters.filter.ContainsKey("users")) { string[] statusIDs; statusIDs = (parameters.filter["users"] as ArrayList).ToArray().Select(x => x.ToString()).ToArray(); if (statusIDs.Length != 0) { items = items.Where(x => SearchArrayPattern(statusIDs, x.users.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))); } } if (parameters.filter.ContainsKey("processID")) { if (parameters.filter["processID"].ToString() != "0") { items = items.Where(x => x.proc_processes.id == RDL.Convert.StrToInt(parameters.filter["processID"].ToString(), 0)); } } } /* ================================================== * if (parameters.filter != null && parameters.filter.Count > 0) * { * var text = parameters.filter.ContainsKey("text") ? parameters.filter["text"].ToString() : ""; * * var sourceID = parameters.filter.ContainsKey("sourceName") ? RDL.Convert.StrToInt(parameters.filter["sourceName"].ToString(), 0) : 0; * items = items.Where(x => (sourceID == 0 || x.sourceID == sourceID)); * * List<int?> statusIDs = new List<int?>(); * if (parameters.filter.ContainsKey("statusName")) * { * statusIDs = (parameters.filter["statusName"] as ArrayList).ToArray().Select(x => (int?)RDL.Convert.StrToInt(x.ToString(), 0)).ToList(); * } * items = items.Where(x => * (statusIDs.Count == 0 || statusIDs.Contains(x.statusID)) * ); * * * var needActive = parameters.filter.ContainsKey("needActive") ? RDL.Convert.StrToInt(parameters.filter["needActive"].ToString(), -1) : -1; * items = items.Where(x => * //фильтр в этом месте не срабатывает для needActive=NULL * (needActive == -1 || x.needActive == (needActive == 1 ? true : false)) * ); * * DateTime nextContactMin = DateTime.MinValue, nextContactMax = DateTime.MaxValue; * if (parameters.filter.ContainsKey("nextContact") && parameters.filter["nextContact"] != null) * { * var dates = parameters.filter["nextContact"].ToString().Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries); * if (dates.Length > 0) * { * nextContactMin = RDL.Convert.StrToDateTime(dates[0].Trim(), DateTime.MinValue); * } * if (dates.Length > 1) * { * nextContactMax = RDL.Convert.StrToDateTime(dates[1].Trim(), DateTime.MaxValue).AddDays(1); * } * items = items.Where(x => * (nextContactMin <= x.nextContact && x.nextContact <= nextContactMax)); * } * * if (text != "") * { * items = items.ToList().Where(x => * x.fio != null && x.fio.IndexOf(text, StringComparison.CurrentCultureIgnoreCase) >= 0 || * x.city != null && x.city.IndexOf(text, StringComparison.CurrentCultureIgnoreCase) >= 0 || * x.note != null && x.note.IndexOf(text, StringComparison.CurrentCultureIgnoreCase) >= 0 || * x.username != null && x.username.IndexOf(text, StringComparison.CurrentCultureIgnoreCase) >= 0 || * x.addedBy != null && x.addedBy.IndexOf(text, StringComparison.CurrentCultureIgnoreCase) >= 0 * ).AsQueryable(); * } * } * * var sorts = parameters.sort.Split(",".ToArray(), StringSplitOptions.RemoveEmptyEntries); * var directions = parameters.direction.Split(",".ToArray(), StringSplitOptions.RemoveEmptyEntries); * var sort1 = sorts.Length > 0 ? sorts[0] : ""; * var direction1 = directions.Length > 0 ? directions[0] : ""; * * var sort2 = sorts.Length > 1 ? sorts[1] : ""; * var direction2 = directions.Length > 1 ? directions[1] : ""; * * IOrderedQueryable<crm_clients> orderedItems = items.OrderByDescending(p => p.created); * * switch (sort1) * { * case "fio": * if (direction1 == "up") orderedItems = items.OrderBy(x => x.fio); * else orderedItems = items.OrderByDescending(x => x.fio); * break; * case "city": * if (direction1 == "up") orderedItems = items.OrderBy(x => x.city); * else orderedItems = items.OrderByDescending(x => x.city); * break; * case "note": * if (direction1 == "up") orderedItems = items.OrderBy(x => x.note); * else orderedItems = items.OrderByDescending(x => x.note); * break; * case "addedBy": * if (direction1 == "up") orderedItems = items.OrderBy(x => x.addedBy); * else orderedItems = items.OrderByDescending(x => x.addedBy); * break; * case "statusName": * if (direction1 == "up") orderedItems = items.OrderBy(x => x.crm_clientStatuses.name); * else orderedItems = items.OrderByDescending(x => x.crm_clientStatuses.name); * break; * case "sourceName": * if (direction1 == "up") orderedItems = items.OrderBy(x => x.crm_sources.name); * else orderedItems = items.OrderByDescending(x => x.crm_sources.name); * break; * case "subchannel": * if (direction1 == "up") orderedItems = items.OrderBy(x => x.subchannel); * else orderedItems = items.OrderByDescending(x => x.subchannel); * break; * case "username": * if (direction1 == "up") orderedItems = items.OrderBy(x => x.username); * else orderedItems = items.OrderByDescending(x => x.username); * break; * case "needActive": * if (direction1 == "up") orderedItems = items.OrderBy(x => x.needActive); * else orderedItems = items.OrderByDescending(x => x.needActive); * break; * case "nextContact": * if (direction1 == "up") orderedItems = items.OrderBy(x => x.nextContact); * else orderedItems = items.OrderByDescending(x => x.nextContact); * break; * * default: * if (direction1 == "up") orderedItems = items.OrderBy(x => x.created); * else orderedItems = items.OrderByDescending(x => x.created); * break; * } * * if (sort2 != "") * { * switch (sort2) * { * case "fio": * if (direction2 == "up") orderedItems = orderedItems.ThenBy(x => x.fio); * else orderedItems = orderedItems.ThenByDescending(x => x.fio); * break; * case "city": * if (direction2 == "up") orderedItems = orderedItems.ThenBy(x => x.city); * else orderedItems = orderedItems.ThenByDescending(x => x.city); * break; * case "note": * if (direction2 == "up") orderedItems = orderedItems.ThenBy(x => x.note); * else orderedItems = orderedItems.ThenByDescending(x => x.note); * break; * case "addedBy": * if (direction2 == "up") orderedItems = orderedItems.ThenBy(x => x.addedBy); * else orderedItems = orderedItems.ThenByDescending(x => x.addedBy); * break; * case "statusName": * if (direction2 == "up") orderedItems = orderedItems.ThenBy(x => x.crm_clientStatuses.name); * else orderedItems = orderedItems.ThenByDescending(x => x.crm_clientStatuses.name); * break; * case "sourceName": * if (direction2 == "up") orderedItems = orderedItems.ThenBy(x => x.crm_sources.name); * else orderedItems = orderedItems.ThenByDescending(x => x.crm_sources.name); * break; * case "subchannel": * if (direction2 == "up") orderedItems = orderedItems.ThenBy(x => x.subchannel); * else orderedItems = orderedItems.ThenByDescending(x => x.subchannel); * break; * case "username": * if (direction2 == "up") orderedItems = orderedItems.ThenBy(x => x.username); * else orderedItems = orderedItems.ThenByDescending(x => x.username); * break; * case "needActive": * if (direction2 == "up") orderedItems = orderedItems.ThenBy(x => x.needActive); * else orderedItems = orderedItems.ThenByDescending(x => x.needActive); * break; * case "nextContact": * if (direction2 == "up") orderedItems = orderedItems.ThenBy(x => x.nextContact); * else orderedItems = orderedItems.ThenByDescending(x => x.nextContact); * break; * * default: * if (direction2 == "up") orderedItems = orderedItems.ThenBy(x => x.created); * else orderedItems = orderedItems.ThenByDescending(x => x.created); * break; * } * } * * var total = orderedItems.Count(); * var res2 = orderedItems.Skip(parameters.pageSize * (parameters.page - 1)).Take(parameters.pageSize).ToList(); */ return(Json(new { items = items.Select(x => new { x.id, name = x.name ?? "", isFinish = x.isFinish ? "Завершен" : "Активен", roles = x.roles ?? "", users = x.users ?? "", processID = x.proc_processes != null ? x.proc_processes.name : "" }), total = items.Count <proc_processItems>() }, JsonRequestBehavior.AllowGet)); }
public async void Dashboard() { // Arrange // mock data for dashboard stored procedure this.QuarryDbContext.ChartEntities.AddRange( new ChartEntity <string, int>() { Id = "WidgetQuarryMaterialCounts-1", Key = "Pie", X = "QM1", Y = 100, KeyOrder = 0, XOrder = 1 }, new ChartEntity <string, int>() { Id = "WidgetQuarryMaterialCounts-2", Key = "Pie", X = "QM2", Y = 200, KeyOrder = 0, XOrder = 2 }, new ChartEntity <string, int>() { Id = "WidgetQuarryProductTypeMaterialCounts-1", Key = "Slab", X = "QM1", Y = 100, KeyOrder = 0, XOrder = 1 }, new ChartEntity <string, int>() { Id = "WidgetQuarryProductTypeMaterialCounts-2", Key = "Slab", X = "QM2", Y = 200, KeyOrder = 0, XOrder = 2 }, new ChartEntity <string, int>() { Id = "WidgetQuarryMaterialColourMaterialCounts-1", Key = "White", X = "QM1", Y = 100, KeyOrder = 0, XOrder = 1 }, new ChartEntity <string, int>() { Id = "WidgetQuarryMaterialColourMaterialCounts-2", Key = "White", X = "QM2", Y = 200, KeyOrder = 0, XOrder = 2 }); // Dashboard data this.AppContext.DashboardPageId = 97; // widget context entities this.WidgetDbContext.Dashboards.Add(new DashboardEntity() { DashboardId = 4, PageId = 97 }); this.WidgetDbContext.DashboardWidgets.AddRange( new DashboardWidgetEntity() { DashboardWidgetId = 1, DashboardId = 4, WidgetId = 1 }, new DashboardWidgetEntity() { DashboardWidgetId = 2, DashboardId = 4, WidgetId = 2 }, new DashboardWidgetEntity() { DashboardWidgetId = 3, DashboardId = 4, WidgetId = 3 }); this.WidgetDbContext.Widgets.AddRange( new WidgetEntity() { WidgetId = 1, Name = "Blocks Per Quarry", Claim = "Quarry:Claim", SizeX = 2, SizeY = 2, ChartTypeId = 2, XAxisLabel = "Top Quarries", YAxisLabel = "Blocks" }, new WidgetEntity() { WidgetId = 2, Name = "Blocks Per Quarry & Product Types", Claim = "Quarry:Claim", SizeX = 4, SizeY = 2, ChartTypeId = 4, XAxisLabel = "Top Quarries", YAxisLabel = "Blocks" }, new WidgetEntity() { WidgetId = 3, Name = "Blocks Per Quarry & Colour", Claim = "Quarry:Claim", SizeX = 6, SizeY = 1, ChartTypeId = 3, XAxisLabel = "Top Quarries", YAxisLabel = "Blocks" }); this.WidgetDbContext.ChartTypes.AddRange( new ChartTypeEntity() { ChartTypeId = 2, Type = "pieChart" }, new ChartTypeEntity() { ChartTypeId = 3, Type = "lineChart" }, new ChartTypeEntity() { ChartTypeId = 4, Type = "multiBarChart" }); this.WidgetDbContext.DashboardPageWidgets.AddRange( new DashboardPageWidgetEntity() { DashboardPageWidgetId = 1, DashboardId = 4, WidgetId = 1, Columns = 4, Rows = 0, SizeX = 2, SizeY = 2, CompanyId = 1 }, new DashboardPageWidgetEntity() { DashboardPageWidgetId = 2, DashboardId = 4, WidgetId = 2, Columns = 0, Rows = 0, SizeX = 4, SizeY = 2, CompanyId = 1 }, new DashboardPageWidgetEntity() { DashboardPageWidgetId = 3, DashboardId = 4, WidgetId = 3, Columns = 0, Rows = 2, SizeX = 6, SizeY = 1, CompanyId = 1 }); await this.SaveChangesAsync(this.QuarryDbContext, this.WidgetDbContext); // Mocking stored procedure var moqChartSp = Mock.Get(this.QuarryDbContext); moqChartSp.Setup(m => m.FromSql <ChartEntity <string, int> >("quarry.WidgetQuarryMaterialCounts @CompanyId = {0}", It.IsAny <object[]>())) .Returns(this.QuarryDbContext.ChartEntities.Where(w => w.Id.Contains("WidgetQuarryMaterialCounts"))); moqChartSp.Setup(m => m.FromSql <ChartEntity <string, int> >("quarry.WidgetQuarryProductTypeMaterialCounts @CompanyId = {0}", It.IsAny <object[]>())) .Returns(this.QuarryDbContext.ChartEntities.Where(w => w.Id.Contains("WidgetQuarryProductTypeMaterialCounts"))); moqChartSp.Setup(m => m.FromSql <ChartEntity <string, int> >("quarry.WidgetQuarryMaterialColourMaterialCounts @CompanyId = {0}", It.IsAny <object[]>())) .Returns(this.QuarryDbContext.ChartEntities.Where(w => w.Id.Contains("WidgetQuarryMaterialColourMaterialCounts"))); // Act AjaxModel <object> ajaxModel = await this.Controller.Dashboard(); DashboardModel dashboard = ajaxModel.Dashboard; // Assert Assert.Null(ajaxModel.Model); Assert.Empty(ajaxModel.Message); Assert.Equal(dashboard.AllWidgets.Count, 3); Assert.Equal(dashboard.PageWidgets.Count, 3); Assert.Equal(dashboard.PageWidgets[1].WidgetId, 1); Assert.Equal(dashboard.AllWidgets[1].WidgetId, 2); Assert.Equal(dashboard.AllWidgets[1].Chart.Type, "multiBarChart"); Assert.Equal(((ChartModel <string, int>)dashboard.AllWidgets[1].Chart.Model).Data[0].Values[1].Y, 200); }
public ActionResult Spec_save() { var parameters = AjaxModel.GetAjaxParameters(HttpContext); var mng = new HRManager(); try { var fields = (parameters["fields"] as ArrayList).ToArray().ToList().Select(x => x as Dictionary <string, object>).ToList(); var newSpec = new hr_specializations { id = (AjaxModel.GetValueFromSaveField("id", fields) == "") ? 0 : int.Parse(AjaxModel.GetValueFromSaveField("id", fields)), name = AjaxModel.GetValueFromSaveField("name", fields), code = AjaxModel.GetValueFromSaveField("code", fields) }; mng.SaveSpec(newSpec); return(Json(new { result = newSpec.id > 0, id = newSpec.id, msg = (newSpec.id > 0) ? "Операция успешна" : "Ошибка" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { RDL.Debug.LogError(ex); return(Json(new { result = false, id = 0, msg = "Ошибка" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Invoices_getItems() { var parameters = AjaxModel.GetParameters(HttpContext); var items = mng.Invoice.GetInvoices().AsQueryable(); int typeID = 0; int contractorID = 0; if (parameters.filter != null && parameters.filter.Count > 0) { var number = parameters.filter.ContainsKey("number") ? parameters.filter["number"].ToString() : ""; if (!String.IsNullOrEmpty(number)) { items = items.Where(x => x.number == number); } //typeID = parameters.filter.ContainsKey("typeID") ? RDL.Convert.StrToInt(parameters.filter["typeID"].ToString(), 0) : 0; //if (typeID > 0) //{ // items = items.Where(x => x.typeID == typeID); //} List <int?> statusIDs = new List <int?>(); if (parameters.filter.ContainsKey("statusIDs")) { statusIDs = (parameters.filter["statusIDs"] as ArrayList).ToArray().Select(x => (int?)RDL.Convert.StrToInt(x.ToString(), 0)).ToList(); //var statusIDs = RDL.Convert.StrToInt(parameters.filter["status"].ToString(), 0); } items = items.Where(x => (statusIDs.Count == 0 || statusIDs.Contains(x.statusID)) ); contractorID = parameters.filter.ContainsKey("contractorID") ? RDL.Convert.StrToInt(parameters.filter["contractorID"].ToString(), 0) : 0; if (contractorID > 0) { items = items.Where(x => x.contractorID == contractorID); } } var sorts = parameters.sort.Split(",".ToArray(), StringSplitOptions.RemoveEmptyEntries); var directions = parameters.direction.Split(",".ToArray(), StringSplitOptions.RemoveEmptyEntries); var sort1 = sorts.Length > 0 ? sorts[0] : ""; var direction1 = directions.Length > 0 ? directions[0] : ""; var sort2 = sorts.Length > 1 ? sorts[1] : ""; var direction2 = directions.Length > 1 ? directions[1] : ""; switch (sort1) { case "number": if (direction1 == "up") { items = items.OrderBy(x => x.number); } else { items = items.OrderByDescending(x => x.number); } break; case "date": if (direction1 == "up") { items = items.OrderBy(x => x.date); } else { items = items.OrderByDescending(x => x.date); } break; //case "type": // if (direction1 == "up") items = items.OrderBy(x => x.typeID); // else items = items.OrderByDescending(x => x.typeID); // break; case "contractor": if (direction1 == "up") { items = items.OrderBy(x => x.contractorID); } else { items = items.OrderByDescending(x => x.contractorID); } break; default: break; } var total = items.Count(); var res2 = items.Skip(parameters.pageSize * (parameters.page - 1)).Take(parameters.pageSize).ToList(); return(Json(new { items = res2.Select(x => new { x.id, date = x.date.ToString("dd.MM.yyyy"), x.contractorID, contractor = x.udovika_contractor != null ? x.udovika_contractor.name : "", x.statusID, status = x.udovika_statusInvoice != null ? x.udovika_statusInvoice.name : "", //x.typeID, //type = x.udovika_contractType != null ? x.udovika_contractType.name : "", //x.link, number = x.number, //x.total, note = x.note }), total = total }, JsonRequestBehavior.AllowGet)); }
public ActionResult DocStatuses_save() { var parameters = AjaxModel.GetAjaxParameters(HttpContext); var fields = (parameters["fields"] as ArrayList).ToArray().ToList().Select(x => x as Dictionary <string, object>).ToList(); var newDocType = new gl_docStatuses { id = (AjaxModel.GetValueFromSaveField("id", fields) == "") ? 0 : int.Parse(AjaxModel.GetValueFromSaveField("id", fields)), name = AjaxModel.GetValueFromSaveField("name", fields), code = AjaxModel.GetValueFromSaveField("code", fields) }; mng.Documents.SaveDocumentStatus(newDocType); return(Json(new { result = true, id = newDocType.id, msg = "Операция успешна" }, JsonRequestBehavior.AllowGet)); }
public async void MaterialColoursGet() { // Arrange this.QuarryDbContext.MaterialColours.AddRange( new MaterialColourEntity() { MaterialColourId = 1, ColourName = "White", CompanyId = 1, DeletedInd = false }, new MaterialColourEntity() { MaterialColourId = 2, ColourName = "Smoky", CompanyId = 1, DeletedInd = false }); // mock data for dashboard stored procedure this.QuarryDbContext.ChartEntities.AddRange( new ChartEntity <string, int>() { Id = "WidgetMaterialColourMaterialCounts-1", Key = "Key", X = "Smoky", Y = 100, KeyOrder = 0, XOrder = 0 }, new ChartEntity <string, int>() { Id = "WidgetMaterialColourMaterialCounts-2", Key = "Key", X = "White", Y = 200, KeyOrder = 0, XOrder = 0 }, new ChartEntity <string, int>() { Id = "WidgetMaterialColourQuarryMaterialCounts-1", Key = "QM1", X = "Smoky", Y = 100, KeyOrder = 0, XOrder = 0 }, new ChartEntity <string, int>() { Id = "WidgetMaterialColourQuarryMaterialCounts-2", Key = "QM1", X = "White", Y = 200, KeyOrder = 0, XOrder = 0 }, new ChartEntity <string, int>() { Id = "WidgetMaterialColourProductTypeMaterialCounts-1", Key = "Slab", X = "Smoky", Y = 100, KeyOrder = 0, XOrder = 0 }, new ChartEntity <string, int>() { Id = "WidgetMaterialColourProductTypeMaterialCounts-2", Key = "Slab", X = "White", Y = 200, KeyOrder = 0, XOrder = 0 }); // Dashboard data this.AppContext.DashboardPageId = 57; // widget context entities this.WidgetDbContext.Dashboards.Add(new DashboardEntity() { DashboardId = 3, PageId = 57 }); this.WidgetDbContext.DashboardWidgets.AddRange( new DashboardWidgetEntity() { DashboardWidgetId = 7, DashboardId = 3, WidgetId = 7 }, new DashboardWidgetEntity() { DashboardWidgetId = 8, DashboardId = 3, WidgetId = 8 }, new DashboardWidgetEntity() { DashboardWidgetId = 9, DashboardId = 3, WidgetId = 9 }); this.WidgetDbContext.Widgets.AddRange( new WidgetEntity() { WidgetId = 7, Name = "Blocks Per Colour", Claim = "Quarry:Claim", SizeX = 2, SizeY = 2, ChartTypeId = 5, XAxisLabel = "Colours", YAxisLabel = "Blocks" }, new WidgetEntity() { WidgetId = 8, Name = "Blocks Per Colour & Quarry", Claim = "Quarry:Claim", SizeX = 4, SizeY = 2, ChartTypeId = 7, XAxisLabel = "Colours", YAxisLabel = "Blocks" }, new WidgetEntity() { WidgetId = 9, Name = "Blocks Per Colour & Product Type", Claim = "Quarry:Claim", SizeX = 6, SizeY = 1, ChartTypeId = 3, XAxisLabel = "Colours", YAxisLabel = "Blocks" }); this.WidgetDbContext.ChartTypes.AddRange( new ChartTypeEntity() { ChartTypeId = 3, Type = "lineChart" }, new ChartTypeEntity() { ChartTypeId = 5, Type = "donutChart" }, new ChartTypeEntity() { ChartTypeId = 7, Type = "stackedBarChart" }); this.WidgetDbContext.DashboardPageWidgets.AddRange( new DashboardPageWidgetEntity() { DashboardPageWidgetId = 7, DashboardId = 3, WidgetId = 7, Columns = 0, Rows = 0, SizeX = 2, SizeY = 2, CompanyId = 1 }, new DashboardPageWidgetEntity() { DashboardPageWidgetId = 8, DashboardId = 3, WidgetId = 8, Columns = 2, Rows = 0, SizeX = 4, SizeY = 2, CompanyId = 1 }, new DashboardPageWidgetEntity() { DashboardPageWidgetId = 9, DashboardId = 3, WidgetId = 9, Columns = 0, Rows = 2, SizeX = 6, SizeY = 1, CompanyId = 1 }); await this.SaveChangesAsync(this.QuarryDbContext, this.WidgetDbContext); // Mocking stored procedure var moqChartSp = Mock.Get(this.QuarryDbContext); moqChartSp.Setup(m => m.FromSql <ChartEntity <string, int> >("quarry.WidgetMaterialColourMaterialCounts @CompanyId = {0}", It.IsAny <object[]>())) .Returns(this.QuarryDbContext.ChartEntities.Where(w => w.Id.Contains("WidgetMaterialColourMaterialCounts"))); moqChartSp.Setup(m => m.FromSql <ChartEntity <string, int> >("quarry.WidgetMaterialColourQuarryMaterialCounts @CompanyId = {0}", It.IsAny <object[]>())) .Returns(this.QuarryDbContext.ChartEntities.Where(w => w.Id.Contains("WidgetMaterialColourQuarryMaterialCounts"))); moqChartSp.Setup(m => m.FromSql <ChartEntity <string, int> >("quarry.WidgetMaterialColourProductTypeMaterialCounts @CompanyId = {0}", It.IsAny <object[]>())) .Returns(this.QuarryDbContext.ChartEntities.Where(w => w.Id.Contains("WidgetMaterialColourProductTypeMaterialCounts"))); // Act AjaxModel <List <MaterialColourModel> > ajaxModel = await this.Controller.MaterialColoursGet(); List <MaterialColourModel> colours = ajaxModel.Model; DashboardModel dashboard = ajaxModel.Dashboard; // Assert Assert.Equal(colours.Count, 2); Assert.Equal(colours[1].ColourName, "White"); Assert.Equal(dashboard.AllWidgets.Count, 3); Assert.Equal(dashboard.PageWidgets.Count, 3); Assert.Equal(dashboard.PageWidgets[1].WidgetId, 8); Assert.Equal(dashboard.AllWidgets[1].WidgetId, 8); Assert.Equal(dashboard.AllWidgets[1].Chart.Type, "stackedBarChart"); Assert.Equal(((ChartModel <string, int>)dashboard.AllWidgets[1].Chart.Model).Data[0].Values[1].Y, 200); }
public async void QuarryUpdate() { // Arrange this.QuarryDbContext.Quarries.AddRange( new QuarryEntity() { QuarryId = 1, QuarryName = "QM1", CompanyId = 1, DeletedInd = false }, new QuarryEntity() { QuarryId = 2, QuarryName = "QM2", CompanyId = 1, DeletedInd = false }); this.QuarryDbContext.Yards.AddRange( new YardEntity() { YardId = 1, YardName = "QM1 Yard", QuarryId = 1, CompanyId = 1, DeletedInd = false }, new YardEntity() { YardId = 2, YardName = "QM2 Yard", QuarryId = 2, CompanyId = 1, DeletedInd = false }); this.QuarryDbContext.MaterialColours.AddRange( new MaterialColourEntity() { MaterialColourId = 1, ColourName = "White", CompanyId = 1, DeletedInd = false }, new MaterialColourEntity() { MaterialColourId = 2, ColourName = "Smoky", CompanyId = 1, DeletedInd = false }); this.QuarryDbContext.QuarryMaterialColours.AddRange( new QuarryMaterialColourEntity() { QuarryMaterialColourId = 1, QuarryId = 2, MaterialColourId = 1, CompanyId = 1, DeletedInd = false }, new QuarryMaterialColourEntity() { QuarryMaterialColourId = 2, QuarryId = 2, MaterialColourId = 2, CompanyId = 1, DeletedInd = false }); await this.SaveChangesAsync(this.QuarryDbContext); QuarryModel model = new QuarryModel() { QuarryId = 2, QuarryName = "QM15", ColourIds = new List <int>() { 2 } }; // Act AjaxModel <NTModel> ajaxModel = await this.Controller.QuarryUpdate(model); // Assert QuarryEntity quarryEntity = this.QuarryDbContext.Quarries.Where(e => e.QuarryId == 2).First(); Assert.Equal(quarryEntity.QuarryName, "QM15"); YardEntity yardEntity = this.QuarryDbContext.Yards.Where(e => e.QuarryId == 2).First(); Assert.Equal(yardEntity.YardName, "QM15 Yard"); List <QuarryMaterialColourEntity> quarryColours = this.QuarryDbContext.QuarryMaterialColours.ToList(); Assert.Equal(quarryColours.Count, 1); Assert.Equal(quarryColours[0].MaterialColourId, 2); Assert.Equal(ajaxModel.Message, QuarryMessages.QuarrySaveSuccess); }
public ActionResult PartnersSpec_save() { var parameters = AjaxModel.GetAjaxParameters(HttpContext); var mng = new PartnersManager(); try { var fields = (parameters["fields"] as ArrayList).ToArray().ToList().Select(x => x as Dictionary <string, object>).ToList(); var newPartnerSpec = new ps_specs { id = (AjaxModel.GetValueFromSaveField("id", fields) == "") ? 0 : int.Parse(AjaxModel.GetValueFromSaveField("id", fields)), name = (AjaxModel.GetValueFromSaveField("name", fields)), }; mng.SavePartnersSpec(newPartnerSpec); return(Json(new { result = true, id = newPartnerSpec.id, mng = "Операция прошла успешно" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { RDL.Debug.LogError(ex); return(Json(new { result = false, id = 0, mng = "Ошибка" }, JsonRequestBehavior.AllowGet)); } }
public async void YardsGet() { // Arrange // adding Yards this.QuarryDbContext.Yards.AddRange( new YardEntity() { YardId = 1, YardName = "Central Yard", CompanyId = 1, DeletedInd = false }, new YardEntity() { YardId = 2, YardName = "NDB Central Yard", CompanyId = 1, DeletedInd = false }); // mock data for dashboard stored procedure this.QuarryDbContext.ChartEntities.AddRange( new ChartEntity <string, int>() { Id = "WidgetYardMaterialCounts-1", Key = "Pie", X = "QM1 Yard", Y = 100, KeyOrder = 0, XOrder = 1 }, new ChartEntity <string, int>() { Id = "WidgetYardMaterialCounts-2", Key = "Pie", X = "QM2 Yard", Y = 200, KeyOrder = 0, XOrder = 2 }, new ChartEntity <string, int>() { Id = "WidgetYardProductTypeMaterialCounts-1", Key = "Slab", X = "QM1 Yard", Y = 100, KeyOrder = 0, XOrder = 1 }, new ChartEntity <string, int>() { Id = "WidgetYardProductTypeMaterialCounts-2", Key = "Slab", X = "QM2 Yard", Y = 200, KeyOrder = 0, XOrder = 2 }); // Dashboard data this.AppContext.DashboardPageId = 11; // widget context entities this.WidgetDbContext.Dashboards.Add(new DashboardEntity() { DashboardId = 5, PageId = 11 }); this.WidgetDbContext.DashboardWidgets.AddRange( new DashboardWidgetEntity() { DashboardWidgetId = 16, DashboardId = 5, WidgetId = 10 }, new DashboardWidgetEntity() { DashboardWidgetId = 17, DashboardId = 5, WidgetId = 11 }); this.WidgetDbContext.Widgets.AddRange( new WidgetEntity() { WidgetId = 10, Name = "Blocks Per Yard", Claim = "Quarry:Claim", SizeX = 2, SizeY = 2, ChartTypeId = 2, XAxisLabel = "Top Yards", YAxisLabel = "Blocks" }, new WidgetEntity() { WidgetId = 11, Name = "Blocks Per Yard & Product Types", Claim = "Quarry:Claim", SizeX = 4, SizeY = 2, ChartTypeId = 4, XAxisLabel = "Top Yards", YAxisLabel = "Blocks" }); this.WidgetDbContext.ChartTypes.AddRange( new ChartTypeEntity() { ChartTypeId = 2, Type = "pieChart" }, new ChartTypeEntity() { ChartTypeId = 4, Type = "multiBarChart" }); this.WidgetDbContext.DashboardPageWidgets.AddRange( new DashboardPageWidgetEntity() { DashboardPageWidgetId = 16, DashboardId = 5, WidgetId = 10, Columns = 0, Rows = 0, SizeX = 2, SizeY = 2, CompanyId = 1 }, new DashboardPageWidgetEntity() { DashboardPageWidgetId = 17, DashboardId = 5, WidgetId = 11, Columns = 2, Rows = 0, SizeX = 4, SizeY = 2, CompanyId = 1 }); await this.SaveChangesAsync(this.QuarryDbContext, this.WidgetDbContext); // Mocking stored procedure var moqChartSp = Mock.Get(this.QuarryDbContext); moqChartSp.Setup(m => m.FromSql <ChartEntity <string, int> >("quarry.WidgetYardMaterialCounts @CompanyId = {0}", It.IsAny <object[]>())) .Returns(this.QuarryDbContext.ChartEntities.Where(w => w.Id.Contains("WidgetYardMaterialCounts"))); moqChartSp.Setup(m => m.FromSql <ChartEntity <string, int> >("quarry.WidgetYardProductTypeMaterialCounts @CompanyId = {0}", It.IsAny <object[]>())) .Returns(this.QuarryDbContext.ChartEntities.Where(w => w.Id.Contains("WidgetYardProductTypeMaterialCounts"))); // Act AjaxModel <List <YardModel> > ajaxModel = await this.Controller.YardsGet(); List <YardModel> yards = ajaxModel.Model; DashboardModel dashboard = ajaxModel.Dashboard; // Assert Assert.Equal(yards.Count, 2); Assert.Equal(yards[1].YardName, "NDB Central Yard"); Assert.Equal(dashboard.AllWidgets.Count, 2); Assert.Equal(dashboard.PageWidgets.Count, 2); Assert.Equal(dashboard.PageWidgets[1].WidgetId, 11); Assert.Equal(dashboard.AllWidgets[1].WidgetId, 11); Assert.Equal(dashboard.AllWidgets[1].Chart.Type, "multiBarChart"); Assert.Equal(((ChartModel <string, int>)dashboard.AllWidgets[1].Chart.Model).Data[0].Values[1].Y, 200); }
public JsonResult ProductDropDownValues([FromBody] AjaxModel value) { var product = _context.Products.Where(p => p.CategoryID == value.CategoryID).ToList(); return(Json(product)); }
public ActionResult GetItems() { var parameters = AjaxModel.GetParameters(HttpContext); var msg = ""; var items = mng.GetAllTemplates(out msg); if (parameters.filter != null && parameters.filter.Count > 0) { var code = parameters.filter.ContainsKey("code") ? parameters.filter["code"].ToString() : ""; items = items.Where(x => x.code.Contains(code)); } var sorts = parameters.sort.Split(",".ToArray(), StringSplitOptions.RemoveEmptyEntries); var directions = parameters.direction.Split(",".ToArray(), StringSplitOptions.RemoveEmptyEntries); var sort1 = sorts.Length > 0 ? sorts[0] : ""; var direction1 = directions.Length > 0 ? directions[0] : ""; switch (sort1) { case "from": if (direction1 == "up") { items = items.OrderBy(x => x.code); } else { items = items.OrderByDescending(x => x.code); } break; case "to": if (direction1 == "up") { items = items.OrderBy(x => x.code); } else { items = items.OrderByDescending(x => x.code); } break; case "subject": if (direction1 == "up") { items = items.OrderBy(x => x.subject); } else { items = items.OrderByDescending(x => x.subject); } break; case "cc": if (direction1 == "up") { items = items.OrderBy(x => x.cc); } else { items = items.OrderByDescending(x => x.cc); } break; case "bcc": if (direction1 == "up") { items = items.OrderBy(x => x.bcc); } else { items = items.OrderByDescending(x => x.bcc); } break; default: case "code": if (direction1 == "up") { items = items.OrderBy(x => x.code); } else { items = items.OrderByDescending(x => x.code); } break; } var total = items.Count(); var res = items.Skip(parameters.pageSize * (parameters.page - 1)).Take(parameters.pageSize).ToList(); return(Json(new { result = items == null, items = res, total, msg })); }
public ActionResult Humans_getItems() { var parameters = AjaxModel.GetParameters(HttpContext); var mng = new HRManager(); var items = mng.GetHumans().AsQueryable(); if (parameters.filter != null && parameters.filter.Count > 0) { var text = parameters.filter.ContainsKey("text") ? parameters.filter["text"].ToString() : ""; var sourceID = parameters.filter.ContainsKey("sourceName") ? RDL.Convert.StrToInt(parameters.filter["sourceName"].ToString(), 0) : 0; items = items.Where(x => (sourceID == 0 || x.sourceID == sourceID) ); List <int?> statusIDs = new List <int?>(); if (parameters.filter.ContainsKey("statusName")) { statusIDs = (parameters.filter["statusName"] as ArrayList).ToArray().Select(x => (int?)RDL.Convert.StrToInt(x.ToString(), 0)).ToList(); } items = items.Where(x => (statusIDs.Count == 0 || statusIDs.Contains(x.statusID)) ); var needActive = parameters.filter.ContainsKey("needActive") ? RDL.Convert.StrToInt(parameters.filter["needActive"].ToString(), -1) : -1; items = items.Where(x => //фильтр в этом месте не срабатывает для needActive=NULL (needActive == -1 || x.needActive == (needActive == 1 ? true : false)) ); if (text != "") { items = items.ToList().Where(x => x.fio != null && x.fio.IndexOf(text, StringComparison.CurrentCultureIgnoreCase) >= 0 || x.city != null && x.city.IndexOf(text, StringComparison.CurrentCultureIgnoreCase) >= 0 || x.note != null && x.note.IndexOf(text, StringComparison.CurrentCultureIgnoreCase) >= 0 || x.username != null && x.username.IndexOf(text, StringComparison.CurrentCultureIgnoreCase) >= 0 || x.addedBy != null && x.addedBy.IndexOf(text, StringComparison.CurrentCultureIgnoreCase) >= 0 || x.pay != null && x.pay.IndexOf(text, StringComparison.CurrentCultureIgnoreCase) >= 0 ).AsQueryable(); } } var sorts = parameters.sort.Split(",".ToArray(), StringSplitOptions.RemoveEmptyEntries); var directions = parameters.direction.Split(",".ToArray(), StringSplitOptions.RemoveEmptyEntries); var sort1 = sorts.Length > 0 ? sorts[0] : ""; var direction1 = directions.Length > 0 ? directions[0] : ""; var sort2 = sorts.Length > 1 ? sorts[1] : ""; var direction2 = directions.Length > 1 ? directions[1] : ""; IOrderedQueryable <hr_humans> orderedItems = items.OrderByDescending(p => p.created); switch (sort1) { case "fio": if (direction1 == "up") { orderedItems = items.OrderBy(x => x.fio); } else { orderedItems = items.OrderByDescending(x => x.fio); } break; case "city": if (direction1 == "up") { orderedItems = items.OrderBy(x => x.city); } else { orderedItems = items.OrderByDescending(x => x.city); } break; case "note": if (direction1 == "up") { orderedItems = items.OrderBy(x => x.note); } else { orderedItems = items.OrderByDescending(x => x.note); } break; case "addedBy": if (direction1 == "up") { orderedItems = items.OrderBy(x => x.addedBy); } else { orderedItems = items.OrderByDescending(x => x.addedBy); } break; case "statusName": if (direction1 == "up") { orderedItems = items.OrderBy(x => x.hr_statuses.name); } else { orderedItems = items.OrderByDescending(x => x.hr_statuses.name); } break; case "sourceName": if (direction1 == "up") { orderedItems = items.OrderBy(x => x.hr_sources.name); } else { orderedItems = items.OrderByDescending(x => x.hr_sources.name); } break; case "subchannel": if (direction1 == "up") { orderedItems = items.OrderBy(x => x.subchannel); } else { orderedItems = items.OrderByDescending(x => x.subchannel); } break; case "username": if (direction1 == "up") { orderedItems = items.OrderBy(x => x.username); } else { orderedItems = items.OrderByDescending(x => x.username); } break; case "needActive": if (direction1 == "up") { orderedItems = items.OrderBy(x => x.needActive); } else { orderedItems = items.OrderByDescending(x => x.needActive); } break; case "pay": if (direction1 == "up") { orderedItems = items.OrderBy(x => x.pay); } else { orderedItems = items.OrderByDescending(x => x.pay); } break; case "hourRate": if (direction1 == "up") { orderedItems = items.OrderBy(x => x.hourRate); } else { orderedItems = items.OrderByDescending(x => x.hourRate); } break; default: if (direction1 == "up") { orderedItems = items.OrderBy(x => x.created); } else { orderedItems = items.OrderByDescending(x => x.created); } break; } if (sort2 != "") { switch (sort2) { case "fio": if (direction2 == "up") { orderedItems = orderedItems.ThenBy(x => x.fio); } else { orderedItems = orderedItems.ThenByDescending(x => x.fio); } break; case "city": if (direction2 == "up") { orderedItems = orderedItems.ThenBy(x => x.city); } else { orderedItems = orderedItems.ThenByDescending(x => x.city); } break; case "note": if (direction2 == "up") { orderedItems = orderedItems.ThenBy(x => x.note); } else { orderedItems = orderedItems.ThenByDescending(x => x.note); } break; case "addedBy": if (direction2 == "up") { orderedItems = orderedItems.ThenBy(x => x.addedBy); } else { orderedItems = orderedItems.ThenByDescending(x => x.addedBy); } break; case "statusName": if (direction2 == "up") { orderedItems = orderedItems.ThenBy(x => x.hr_statuses.name); } else { orderedItems = orderedItems.ThenByDescending(x => x.hr_statuses.name); } break; case "sourceName": if (direction2 == "up") { orderedItems = orderedItems.ThenBy(x => x.hr_sources.name); } else { orderedItems = orderedItems.ThenByDescending(x => x.hr_sources.name); } break; case "subchannel": if (direction2 == "up") { orderedItems = orderedItems.ThenBy(x => x.subchannel); } else { orderedItems = orderedItems.ThenByDescending(x => x.subchannel); } break; case "username": if (direction2 == "up") { orderedItems = orderedItems.ThenBy(x => x.username); } else { orderedItems = orderedItems.ThenByDescending(x => x.username); } break; case "needActive": if (direction2 == "up") { orderedItems = orderedItems.ThenBy(x => x.needActive); } else { orderedItems = orderedItems.ThenByDescending(x => x.needActive); } break; case "pay": if (direction2 == "up") { orderedItems = orderedItems.ThenBy(x => x.pay); } else { orderedItems = orderedItems.ThenByDescending(x => x.pay); } break; case "hourRate": if (direction2 == "up") { orderedItems = orderedItems.ThenBy(x => x.hourRate); } else { orderedItems = orderedItems.ThenByDescending(x => x.hourRate); } break; default: if (direction2 == "up") { orderedItems = orderedItems.ThenBy(x => x.created); } else { orderedItems = orderedItems.ThenByDescending(x => x.created); } break; } } var total = orderedItems.Count(); var res2 = orderedItems.Skip(parameters.pageSize * (parameters.page - 1)).Take(parameters.pageSize).ToList(); return(Json(new { items = res2.Select(x => new { x.id, fio = x.fio ?? "", city = x.city ?? "", note = x.note ?? "", x.sourceID, sourceName = x.hr_sources != null ? x.hr_sources.name : "", x.statusID, statusName = x.hr_statuses != null ? x.hr_statuses.name : "", addedBy = x.addedBy ?? "", created = x.created.GetValueOrDefault().ToString("dd.MM.yyyy"), subchannel = x.subchannel ?? "", username = x.username ?? "", needActive = x.needActive.HasValue && x.needActive == true ? "Да" : "Нет", pay = x.pay ?? "", hourRate = x.hourRate ?? 0 }), total = total }, JsonRequestBehavior.AllowGet)); }
public ActionResult DocumentsList_getItems() { var parameters = AjaxModel.GetParameters(HttpContext); var user = mng.GetUser(); string msg = ""; var items = mng.Documents.GetDocuments(user, out msg); if (parameters.filter != null && parameters.filter.Count > 0) { var text = parameters.filter.ContainsKey("text") ? parameters.filter["text"].ToString() : ""; if (text != "") { items = items.Where(x => x.number != null && x.number.Contains(text)).ToList(); } var ctrgID = parameters.filter.ContainsKey("ctrgID") ? RDL.Convert.StrToInt(parameters.filter["ctrgID"].ToString(), 0) : 0; if (ctrgID != 0) { items = items.Where(x => x.contragentID == ctrgID).ToList(); } var docTypeID = parameters.filter.ContainsKey("docTypeID") ? RDL.Convert.StrToInt(parameters.filter["docTypeID"].ToString(), 0) : 0; if (docTypeID != 0) { items = items.Where(x => x.docTypeID == docTypeID).ToList(); } var parentDocID = parameters.filter.ContainsKey("parentDocID") ? RDL.Convert.StrToInt(parameters.filter["parentDocID"].ToString(), 0) : 0; if (parentDocID != 0) { items = items.Where(x => x.docParentID == parentDocID).ToList(); } List <int?> statusIDs = new List <int?>(); if (parameters.filter.ContainsKey("statusIDs")) { statusIDs = (parameters.filter["statusIDs"] as ArrayList).ToArray().Select(x => (int?)RDL.Convert.StrToInt(x.ToString(), 0)).ToList(); } if (statusIDs.Count != 0) { items = items.Where(x => statusIDs.Contains(x.docStatusID)).ToList(); } } var sorts = parameters.sort.Split(",".ToArray(), StringSplitOptions.RemoveEmptyEntries); var directions = parameters.direction.Split(",".ToArray(), StringSplitOptions.RemoveEmptyEntries); var sort1 = sorts.Length > 0 ? sorts[0] : ""; var direction1 = directions.Length > 0 ? directions[0] : ""; switch (sort1) { case "number": if (direction1 == "up") { items = items.OrderBy(x => x.number).ToList(); } else { items = items.OrderByDescending(x => x.number).ToList(); } break; case "email": if (direction1 == "up") { items = items.OrderBy(x => x.date).ToList(); } else { items = items.OrderByDescending(x => x.date).ToList(); } break; case "sum": if (direction1 == "up") { items = items.OrderBy(x => x.sum).ToList(); } else { items = items.OrderByDescending(x => x.sum).ToList(); } break; default: if (direction1 == "up") { items = items.OrderBy(x => x.number).ToList(); } else { items = items.OrderByDescending(x => x.number).ToList(); } break; } var total = items.Count(); var res = items.Skip(parameters.pageSize * (parameters.page - 1)).Take(parameters.pageSize).ToList(); var json = JsonConvert.SerializeObject(new { items = res.Select(x => new { id = x.id, uniqueCode = x.uniqueCode, date = x.date.ToShortDateString(), number = x.number, sum = x.sum, description = x.description, link = x.link, isDeleted = x.isDeleted, contragentName = x.h_contragents != null ? x.h_contragents.name : "undefined", docStatus = x.h_docStatuses != null ? x.h_docStatuses.name : "undefined", docTypes = x.h_docTypes != null ? x.h_docTypes.name : "undefined", ParentDocs = x.h_documents2 != null ? x.h_documents2.number : "undefined" }), msg = msg, total = total } ); return(Content(json, "application/json")); }
public ActionResult Mails_getItems() { var parameters = AjaxModel.GetParameters(HttpContext); var from = ""; var to = ""; var statusID = 0; var numberTrack = ""; var numberTrackBack = ""; DateTime createdMin = (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue; DateTime createdMax = (DateTime)System.Data.SqlTypes.SqlDateTime.MaxValue; if (parameters.filter != null && parameters.filter.Count > 0) { from = parameters.filter.ContainsKey("from") ? parameters.filter["from"].ToString() : ""; to = parameters.filter.ContainsKey("to") ? parameters.filter["to"].ToString() : ""; statusID = parameters.filter.ContainsKey("statusName") ? RDL.Convert.StrToInt(parameters.filter["statusName"].ToString(), 0) : 0; numberTrack = parameters.filter.ContainsKey("numberTrack") ? parameters.filter["numberTrack"].ToString() : ""; numberTrackBack = parameters.filter.ContainsKey("numberTrackBack") ? parameters.filter["numberTrackBack"].ToString() : ""; if (parameters.filter.ContainsKey("date") && parameters.filter["date"] != null) { var dates = parameters.filter["date"].ToString().Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries); if (dates.Length > 0) { createdMin = RDL.Convert.StrToDateTime(dates[0].Trim(), (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue); } if (dates.Length > 1) { createdMax = RDL.Convert.StrToDateTime(dates[1].Trim(), (DateTime)System.Data.SqlTypes.SqlDateTime.MaxValue); } } } var sorts = parameters.sort.Split(",".ToArray(), StringSplitOptions.RemoveEmptyEntries); var directions = parameters.direction.Split(",".ToArray(), StringSplitOptions.RemoveEmptyEntries); var sort1 = sorts.Length > 0 ? sorts[0] : ""; var direction1 = directions.Length > 0 ? directions[0] : ""; var rep = new CoreRepository(); var p = new DynamicParameters(); p.Add("from", from); p.Add("to", to); p.Add("statusID", statusID); p.Add("numberTrack", numberTrack); p.Add("numberTrackBack", numberTrackBack); p.Add("createdMin", createdMin); p.Add("createdMax", createdMax); p.Add("sort1", sort1); p.Add("direction1", direction1); p.Add("page", parameters.page); p.Add("pageSize", parameters.pageSize); p.Add("total", dbType: DbType.Int32, direction: ParameterDirection.Output); var items = rep.GetSQLData <dynamic>("Gurevskiy_GetMails", p, CommandType.StoredProcedure); var total = p.Get <int>("total"); var json = JsonConvert.SerializeObject(new { items, total = total }); return(Content(json, "application/json")); }
public ActionResult SqlCrud_getItems() { var parameters = AjaxModel.GetParameters(HttpContext); var mng = new SqlCrudManager(); IQueryable <as_sqlGet> items = mng.GetSqlCruds().AsQueryable(); if (parameters.filter != null && parameters.filter.Count > 0) { var code = parameters.filter.ContainsKey("code") ? parameters.filter["code"].ToString() : ""; List <string> roles = new List <string>(); if (parameters.filter.ContainsKey("roles")) { roles = (parameters.filter["roles"] as ArrayList).ToArray().Select(x => x.ToString()).ToList(); } items = items.Where(x => (roles.Count == 0 || x.as_sqlRole.Select(z => z.role).ToList().Intersect(roles).Count() > 0) ); if (code != "") { items = items.ToList().Where(x => x.code != null && x.code.IndexOf(code, StringComparison.CurrentCultureIgnoreCase) >= 0 || x.code != null && x.code.IndexOf(code, StringComparison.CurrentCultureIgnoreCase) >= 0).AsQueryable(); } } var res = items; var sorts = parameters.sort.Split(",".ToArray(), StringSplitOptions.RemoveEmptyEntries); var directions = parameters.direction.Split(",".ToArray(), StringSplitOptions.RemoveEmptyEntries); var sort1 = sorts.Length > 0 ? sorts[0] : ""; var direction1 = directions.Length > 0 ? directions[0] : ""; switch (sort1) { case "code": if (direction1 == "up") { res = res.OrderBy(x => x.code); } else { res = res.OrderByDescending(x => x.code); } break; default: if (direction1 == "up") { res = res.OrderBy(x => x.id); } else { res = res.OrderByDescending(x => x.id); } break; } var total = res.Count(); var res2 = res.Skip(parameters.pageSize * (parameters.page - 1)).Take(parameters.pageSize).ToList(); return(Json(new { items = res2.Select(x => new { x.id, sql = x.sql ?? "", code = x.code ?? "", users = x.users ?? "", roles = "<div class='usUserRoles'>" + String.Join(",", x.as_sqlRole.Select(z => z.role)) + "</div>" }), total = total }, JsonRequestBehavior.AllowGet)); }
public ActionResult Mails_getItems() { var parameters = AjaxModel.GetParameters(HttpContext); var items = mng.Mail.GetMails().AsQueryable(); if (parameters.filter != null && parameters.filter.Count > 0) { var trackNum = parameters.filter.ContainsKey("trackNum") ? parameters.filter["trackNum"].ToString() : ""; if (!String.IsNullOrEmpty(trackNum)) { items = items.Where(x => x.trackNum == trackNum); } var from = parameters.filter.ContainsKey("from") ? parameters.filter["from"].ToString() : ""; if (!String.IsNullOrEmpty(from)) { items = items.Where(x => x.from == from); } var to = parameters.filter.ContainsKey("to") ? parameters.filter["to"].ToString() : ""; if (!String.IsNullOrEmpty(to)) { items = items.Where(x => x.to == to); } List <int?> statusIDs = new List <int?>(); if (parameters.filter.ContainsKey("statusIDs")) { statusIDs = (parameters.filter["statusIDs"] as ArrayList).ToArray().Select(x => (int?)RDL.Convert.StrToInt(x.ToString(), 0)).ToList(); } items = items.Where(x => (statusIDs.Count == 0 || statusIDs.Contains(x.statusID)) ); //var contractorID = parameters.filter.ContainsKey("contractorID") ? RDL.Convert.StrToInt(parameters.filter["contractorID"].ToString(), 0) : 0; //if (contractorID > 0) //{ // items = items.Where(x => x.contractorID == contractorID); //} } var sorts = parameters.sort.Split(",".ToArray(), StringSplitOptions.RemoveEmptyEntries); var directions = parameters.direction.Split(",".ToArray(), StringSplitOptions.RemoveEmptyEntries); var sort1 = sorts.Length > 0 ? sorts[0] : ""; var direction1 = directions.Length > 0 ? directions[0] : ""; var sort2 = sorts.Length > 1 ? sorts[1] : ""; var direction2 = directions.Length > 1 ? directions[1] : ""; switch (sort1) { case "number": if (direction1 == "up") { items = items.OrderBy(x => x.trackNum); } else { items = items.OrderByDescending(x => x.trackNum); } break; case "date": if (direction1 == "up") { items = items.OrderBy(x => x.date); } else { items = items.OrderByDescending(x => x.date); } break; //case "contractor": // if (direction1 == "up") items = items.OrderBy(x => x.contractorID); // else items = items.OrderByDescending(x => x.contractorID); // break; default: break; } var total = items.Count(); var res2 = items.Skip(parameters.pageSize * (parameters.page - 1)).Take(parameters.pageSize).ToList(); return(Json(new { items = res2.Select(x => new { x.id, date = x.date.ToString("dd.MM.yyyy"), //x.contractorID, //contractor = x.udovika_contractor != null ? x.udovika_contractor.name : "", x.statusID, status = x.udovika_statusEmail != null ? x.udovika_statusEmail.name : "", trackNum = x.trackNum, backNum = x.backNum, from = x.from, to = x.to, system = x.system, backDate = x.backDate.ToString("dd.MM.yyyy"), description = x.description }), //total = total }, JsonRequestBehavior.AllowGet)); }
public async void ProductTypesGet() { // Arrange // adding Product Types this.QuarryDbContext.ProductTypes.AddRange( new ProductTypeEntity() { ProductTypeId = 1, ProductTypeName = "Slab", CompanyId = 1, DeletedInd = false }, new ProductTypeEntity() { ProductTypeId = 2, ProductTypeName = "Tile", CompanyId = 1, DeletedInd = false }); // mock data for dashboard stored procedure this.QuarryDbContext.ChartEntities.AddRange( new ChartEntity <string, int>() { Id = "WidgetProductTypeMaterialCounts-1", Key = "Key", X = "Slab", Y = 100, KeyOrder = 0, XOrder = 1 }, new ChartEntity <string, int>() { Id = "WidgetProductTypeMaterialCounts-2", Key = "Key", X = "Tile", Y = 200, KeyOrder = 0, XOrder = 2 }, new ChartEntity <string, int>() { Id = "WidgetProductTypeQuarryMaterialCounts-1", Key = "QM1", X = "Slab", Y = 100, KeyOrder = 0, XOrder = 1 }, new ChartEntity <string, int>() { Id = "WidgetProductTypeQuarryMaterialCounts-2", Key = "QM1", X = "Tile", Y = 200, KeyOrder = 0, XOrder = 2 }, new ChartEntity <string, int>() { Id = "WidgetProductTypeMaterialColourMaterialCounts-1", Key = "Multi-Color", X = "Slab", Y = 100, KeyOrder = 0, XOrder = 1 }, new ChartEntity <string, int>() { Id = "WidgetProductTypeMaterialColourMaterialCounts-2", Key = "Multi-Color", X = "Tile", Y = 200, KeyOrder = 0, XOrder = 2 }); // Dashboard data this.AppContext.DashboardPageId = 56; // widget context entities this.WidgetDbContext.Dashboards.Add(new DashboardEntity() { DashboardId = 2, PageId = 56 }); this.WidgetDbContext.DashboardWidgets.AddRange( new DashboardWidgetEntity() { DashboardWidgetId = 4, DashboardId = 2, WidgetId = 4 }, new DashboardWidgetEntity() { DashboardWidgetId = 5, DashboardId = 2, WidgetId = 5 }, new DashboardWidgetEntity() { DashboardWidgetId = 6, DashboardId = 2, WidgetId = 6 }); this.WidgetDbContext.Widgets.AddRange( new WidgetEntity() { WidgetId = 4, Name = "Blocks Per Product Type", Claim = "Quarry:Claim", SizeX = 3, SizeY = 2, ChartTypeId = 1, XAxisLabel = "Product Types", YAxisLabel = "Blocks" }, new WidgetEntity() { WidgetId = 5, Name = "Blocks Per Product Types & Quarry", Claim = "Quarry:Claim", SizeX = 3, SizeY = 2, ChartTypeId = 4, XAxisLabel = "Product Types", YAxisLabel = "Blocks" }, new WidgetEntity() { WidgetId = 6, Name = "Blocks Per Product Type & Colour", Claim = "Quarry:Claim", SizeX = 6, SizeY = 1, ChartTypeId = 6, XAxisLabel = "Product Types", YAxisLabel = "Blocks" }); this.WidgetDbContext.ChartTypes.AddRange( new ChartTypeEntity() { ChartTypeId = 1, Type = "discreteBarChart" }, new ChartTypeEntity() { ChartTypeId = 4, Type = "multiBarChart" }, new ChartTypeEntity() { ChartTypeId = 6, Type = "stackedAreaChart" }); this.WidgetDbContext.DashboardPageWidgets.AddRange( new DashboardPageWidgetEntity() { DashboardPageWidgetId = 4, DashboardId = 2, WidgetId = 4, Columns = 0, Rows = 0, SizeX = 3, SizeY = 2, CompanyId = 1 }, new DashboardPageWidgetEntity() { DashboardPageWidgetId = 5, DashboardId = 2, WidgetId = 5, Columns = 3, Rows = 0, SizeX = 3, SizeY = 2, CompanyId = 1 }, new DashboardPageWidgetEntity() { DashboardPageWidgetId = 6, DashboardId = 2, WidgetId = 6, Columns = 0, Rows = 2, SizeX = 6, SizeY = 1, CompanyId = 1 }); await this.SaveChangesAsync(this.QuarryDbContext, this.WidgetDbContext); // Mocking stored procedure var moqChartSp = Mock.Get(this.QuarryDbContext); moqChartSp.Setup(m => m.FromSql <ChartEntity <string, int> >("quarry.WidgetProductTypeMaterialCounts @CompanyId = {0}", It.IsAny <object[]>())) .Returns(this.QuarryDbContext.ChartEntities.Where(w => w.Id.Contains("WidgetProductTypeMaterialCounts"))); moqChartSp.Setup(m => m.FromSql <ChartEntity <string, int> >("quarry.WidgetProductTypeQuarryMaterialCounts @CompanyId = {0}", It.IsAny <object[]>())) .Returns(this.QuarryDbContext.ChartEntities.Where(w => w.Id.Contains("WidgetProductTypeQuarryMaterialCounts"))); moqChartSp.Setup(m => m.FromSql <ChartEntity <string, int> >("quarry.WidgetProductTypeMaterialColourMaterialCounts @CompanyId = {0}", It.IsAny <object[]>())) .Returns(this.QuarryDbContext.ChartEntities.Where(w => w.Id.Contains("WidgetProductTypeMaterialColourMaterialCounts"))); // Act AjaxModel <List <ProductTypeModel> > ajaxModel = await this.Controller.ProductTypesGet(); List <ProductTypeModel> productTypes = ajaxModel.Model; DashboardModel dashboard = ajaxModel.Dashboard; // Assert Assert.Equal(productTypes.Count, 2); Assert.Equal(productTypes[1].ProductTypeName, "Tile"); Assert.Equal(dashboard.AllWidgets.Count, 3); Assert.Equal(dashboard.PageWidgets.Count, 3); Assert.Equal(dashboard.PageWidgets[1].WidgetId, 5); Assert.Equal(dashboard.AllWidgets[1].WidgetId, 5); Assert.Equal(dashboard.AllWidgets[1].Chart.Type, "multiBarChart"); Assert.Equal(((ChartModel <string, int>)dashboard.AllWidgets[1].Chart.Model).Data[0].Values[1].Y, 200); }
public ActionResult Contract_getItems() { var parameters = AjaxModel.GetParameters(HttpContext); var number = ""; var date = ""; var contagentID = ""; var summa = ""; var desc = ""; var statusID = ""; var link = ""; DateTime createdMin = (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue; DateTime createdMax = (DateTime)System.Data.SqlTypes.SqlDateTime.MaxValue; if (parameters.filter != null && parameters.filter.Count > 0) { number = parameters.filter.ContainsKey("number") ? parameters.filter["number"].ToString() : ""; date = parameters.filter.ContainsKey("date") ? parameters.filter["date"].ToString() : ""; statusID = parameters.filter.ContainsKey("statusID") ? parameters.filter["statusID"].ToString() : "0"; contagentID = parameters.filter.ContainsKey("contagentID") ? parameters.filter["contagentID"].ToString() : "0"; if (parameters.filter.ContainsKey("date") && parameters.filter["date"] != null) { var dates = parameters.filter["date"].ToString().Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries); if (dates.Length > 0) { createdMin = RDL.Convert.StrToDateTime(dates[0].Trim(), (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue); } if (dates.Length > 1) { createdMax = RDL.Convert.StrToDateTime(dates[1].Trim(), (DateTime)System.Data.SqlTypes.SqlDateTime.MaxValue); createdMax = createdMax.AddDays(1).AddSeconds(-1); } } } var sorts = parameters.sort.Split(",".ToArray(), StringSplitOptions.RemoveEmptyEntries); var directions = parameters.direction.Split(",".ToArray(), StringSplitOptions.RemoveEmptyEntries); var sort1 = sorts.Length > 0 ? sorts[0] : ""; var direction1 = directions.Length > 0 ? directions[0] : ""; var rep = new CoreRepository(); var p = new DynamicParameters(); p.Add("number", number); p.Add("contagentID", contagentID); p.Add("statusID", statusID); p.Add("sort1", sort1); p.Add("direction1", direction1); p.Add("createdMin", createdMin); p.Add("createdMax", createdMax); p.Add("page", parameters.page); p.Add("pageSize", parameters.pageSize); p.Add("total", dbType: DbType.Int32, direction: ParameterDirection.Output); var items = rep.GetSQLData <dynamic>("GetContractsMikh", p, CommandType.StoredProcedure) as List <dynamic> ?? new List <dynamic>(); var total = p.Get <int>("total"); var json = JsonConvert.SerializeObject(new { items, total = total }); return(Content(json, "application/json")); }
public ActionResult Table_getItems() { var parameters = AjaxModel.GetParameters(HttpContext); string userName = ""; string searchText = ""; object correct = null; if (parameters.filter != null && parameters.filter.Count > 0) { userName = parameters.filter.ContainsKey("user") ? (parameters.filter["user"].ToString() != "0" ? parameters.filter["user"].ToString() : "") : ""; searchText = parameters.filter.ContainsKey("searchText") ? (parameters.filter["searchText"].ToString() != "0" ? parameters.filter["searchText"].ToString() : "") : ""; correct = parameters.filter.ContainsKey("correct") ? parameters.filter["correct"] : null; } string[] sorts = parameters.sort.Split(",".ToArray(), StringSplitOptions.RemoveEmptyEntries); string sort1 = sorts.Length > 0 ? sorts[0] : ""; string[] directions = parameters.direction.Split(",".ToArray(), StringSplitOptions.RemoveEmptyEntries); string direction1 = directions.Length > 0 ? directions[0] : ""; var rep = new CoreRepository(); var param = new DynamicParameters(); param.Add("UserName", userName); param.Add("SelectText", searchText); param.Add("Correct", correct); param.Add("SortField", sort1); param.Add("Directions", direction1); param.Add("page", parameters.page); param.Add("pageSize", parameters.pageSize); param.Add("total", dbType: DbType.Int32, direction: ParameterDirection.Output); var items = rep.GetSQLData <dynamic>("[GetTextMistakesTable]", param, CommandType.StoredProcedure); var res = new List <object>(); var usersList = new List <object>(); try { foreach (var item in (items as List <dynamic>)) { res.Add(new { item.id, user = item.userName != null ? item.userName : "", item.selectText, item.url, item.comment, correct = item.correct ? "да" : "нет" }); usersList.Add(new { user = item.userName != null ? item.userName : "" }); } } catch (NullReferenceException e) { Console.WriteLine(e); } var json = JsonConvert.SerializeObject(new { items = res, total = res.Count }); return(Content(json, "application/json")); }
public ActionResult DeliverySystemsList_getItems() { var parameters = AjaxModel.GetParameters(HttpContext); var user = mng.GetUser(); string msg = ""; var items = mng.Mails.GetDeliverySystems(out msg, user); if (parameters.filter != null && parameters.filter.Count > 0) { var text = parameters.filter.ContainsKey("text") ? parameters.filter["text"].ToString() : ""; if (text != "") { items = items.Where(x => x.name != null && x.name.Contains(text)).ToList(); } } var sorts = parameters.sort.Split(",".ToArray(), StringSplitOptions.RemoveEmptyEntries); var directions = parameters.direction.Split(",".ToArray(), StringSplitOptions.RemoveEmptyEntries); var sort1 = sorts.Length > 0 ? sorts[0] : ""; var direction1 = directions.Length > 0 ? directions[0] : ""; switch (sort1) { case "name": if (direction1 == "up") { items = items.OrderBy(x => x.name).ToList(); } else { items = items.OrderByDescending(x => x.name).ToList(); } break; case "email": if (direction1 == "up") { items = items.OrderBy(x => x.code).ToList(); } else { items = items.OrderByDescending(x => x.code).ToList(); } break; default: if (direction1 == "up") { items = items.OrderBy(x => x.name).ToList(); } else { items = items.OrderByDescending(x => x.name).ToList(); } break; } var total = items.Count(); var res = items.Skip(parameters.pageSize * (parameters.page - 1)).Take(parameters.pageSize).ToList(); var json = JsonConvert.SerializeObject(new { items = res.Select(x => new { id = x.id, name = x.name, code = x.code }), msg = msg, total = total }); return(Content(json, "application/json")); }
public ActionResult ParsingGo() { var res = false; var msg = ""; var url = ""; try { var parameters = AjaxModel.GetAjaxParameters(HttpContext); var fields = (parameters["fields"] as ArrayList).ToArray().ToList().Select(x => x as Dictionary <string, object>).ToList(); var words = AjaxModel.GetValueFromSaveField("words", fields).ToLower().Trim().Replace(" ", string.Empty); var word = ""; var i = 0; List <string> keys = new List <string>(); while (i < words.Length) { if (words[i] == '\n') { if (word != "") { keys.Add(word); } word = ""; } else { word += words[i]; } i++; } ; if (word != "") { keys.Add(word); } List <ParseItem> items = new List <ParseItem>(); var b = keys; for (i = 0; i < keys.Count; i++) { var a = CustomParsePage(i, "https://websta.me/search/" + keys[i], items, keys[i]); Thread.Sleep(400); if (a != "") { msg = a; res = false; return(Json(new { result = res, msg = msg }, JsonRequestBehavior.AllowGet)); } } if (items.Count == 0) { msg = "Нет элементов"; res = false; return(Json(new { result = res, msg = msg }, JsonRequestBehavior.AllowGet)); } url = SaveFile(items); msg = "<a href='" + url + "'>Ссылка на excel-файл</a>"; res = true; } catch (Exception ex) { res = false; msg = ex.Message; } var json = JsonConvert.SerializeObject(new { result = res, msg = msg, url = url }); return(Content(json, "application/json")); }
public ActionResult InvoicesStatuses_save() { var parameters = AjaxModel.GetAjaxParameters(HttpContext); try { var fields = (parameters["fields"] as ArrayList).ToArray().ToList().Select(x => x as Dictionary <string, object>).ToList(); var newInvoicesStatus = new pdv_invoiceStatuses { id = (AjaxModel.GetValueFromSaveField("id", fields) == "") ? 0 : int.Parse(AjaxModel.GetValueFromSaveField("id", fields)), name = AjaxModel.GetValueFromSaveField("name", fields), code = AjaxModel.GetValueFromSaveField("code", fields) }; mng.Invoices.SaveInvoicesStatus(newInvoicesStatus); return(Json(new { result = true, id = newInvoicesStatus.id, msg = "Операция успешна" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { RDL.Debug.LogError(ex); return(Json(new { result = false, id = 0, msg = "Ошибка" }, JsonRequestBehavior.AllowGet)); } }
public JsonResult DropDownVal([FromBody] AjaxModel val) { var product = _context.Products.Where(p => p.CategoryName == val.CategoryName).ToList(); return(Json(product)); }
public JsonResult GetProductPrice([FromBody] AjaxModel value) { var product = _context.Products.Where(p => p.ID == value.ProductID); return(Json(product)); }
//public ActionResult ItemLogs_getItems() //{ // var parameters = AjaxModel.GetParameters(HttpContext); // var mng = new ImpManager(); // DateTime createdMin = (DateTime) System.Data.SqlTypes.SqlDateTime.MinValue; // DateTime createdMax = (DateTime) System.Data.SqlTypes.SqlDateTime.MaxValue; // var isImport = -1; // var withBackup = -1; // var itemID = 0; // //---------------обработка фильтров // if (parameters.filter != null && parameters.filter.Count > 0) // { // if (parameters.filter.ContainsKey("created") && parameters.filter["created"] != null) // { // var dates = parameters.filter["created"].ToString().Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries); // if (dates.Length > 0) // { // createdMin = RDL.Convert.StrToDateTime(dates[0].Trim(), (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue); // } // if (dates.Length > 1) // { // createdMax = RDL.Convert.StrToDateTime(dates[1].Trim(), (DateTime)System.Data.SqlTypes.SqlDateTime.MaxValue); // } // } // if (parameters.filter.ContainsKey("isImport") && parameters.filter["isImport"] != null) // { // isImport = RDL.Convert.StrToInt(parameters.filter["isImport"].ToString(), 0); // } // if (parameters.filter.ContainsKey("withBackup") && parameters.filter["withBackup"] != null) // { // withBackup = RDL.Convert.StrToInt(parameters.filter["withBackup"].ToString(), 0); // } // if (parameters.filter.ContainsKey("itemId") && parameters.filter["itemId"] != null) // { // itemID = RDL.Convert.StrToInt(parameters.filter["itemId"].ToString(), 0); // if (itemID == -1) itemID = 0; // } // } // var sorts = parameters.sort.Split(",".ToArray(), StringSplitOptions.RemoveEmptyEntries); // var directions = parameters.direction.Split(",".ToArray(), StringSplitOptions.RemoveEmptyEntries); // var sort1 = sorts.Length > 0 ? sorts[0] : ""; // var direction1 = directions.Length > 0 ? directions[0] : ""; // var rep = new ImpRepository(); // var p = new DynamicParameters(); // p.Add("isImport",isImport); // p.Add("withBackup",withBackup); // p.Add("itemID",itemID); // p.Add("createdMin",createdMin); // p.Add("createdMax",createdMax); // p.Add("sort1", sort1); // p.Add("direction1", direction1); // p.Add("page", parameters.page); // p.Add("pageSize", parameters.pageSize); // p.Add("total", dbType: DbType.Int32, direction: ParameterDirection.Output); // var items = rep.GetSQLData<dynamic>("GetItemLogs", p, CommandType.StoredProcedure); // var total = p.Get<int>("total"); // var json = JsonConvert.SerializeObject(new // { // items, // total = total // }); // return Content(json, "application/json"); //} public ActionResult ItemLogs_getItems() { var parameters = AjaxModel.GetParameters(HttpContext); var mng = new ImpManager(); var items = mng.GetItemLogs().AsQueryable(); //---------------обработка фильтров if (parameters.filter != null && parameters.filter.Count > 0) { DateTime createdMin = (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue; DateTime createdMax = (DateTime)System.Data.SqlTypes.SqlDateTime.MaxValue; if (parameters.filter.ContainsKey("created") && parameters.filter["created"] != null) { var dates = parameters.filter["created"].ToString().Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries); if (dates.Length > 0) { createdMin = RDL.Convert.StrToDateTime(dates[0].Trim(), (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue); } if (dates.Length > 1) { createdMax = RDL.Convert.StrToDateTime(dates[1].Trim(), (DateTime)System.Data.SqlTypes.SqlDateTime.MaxValue); } items = items.Where(x => x.created >= createdMin && x.created <= createdMax).AsQueryable(); } if (parameters.filter.ContainsKey("isImport") && parameters.filter["isImport"] != null) { var isImport = RDL.Convert.StrToInt(parameters.filter["isImport"].ToString(), 0); if (isImport == 1) { items = items.Where(x => x.isImport == true).AsQueryable(); } if (isImport == 0) { items = items.Where(x => x.isImport == false).AsQueryable(); } } if (parameters.filter.ContainsKey("withBackup") && parameters.filter["withBackup"] != null) { var withBackup = RDL.Convert.StrToInt(parameters.filter["withBackup"].ToString(), 0); if (withBackup == 0) { items = items.Where(x => x.withBackup == false).AsQueryable(); } if (withBackup == 1) { items = items.Where(x => x.withBackup == true).AsQueryable(); } } if (parameters.filter.ContainsKey("itemId") && parameters.filter["itemId"] != null) { var itemID = RDL.Convert.StrToInt(parameters.filter["itemId"].ToString(), 0); if (itemID != -1) { items = items.Where(x => x.itemID == itemID).AsQueryable(); } } } var sorts = parameters.sort.Split(",".ToArray(), StringSplitOptions.RemoveEmptyEntries); var directions = parameters.direction.Split(",".ToArray(), StringSplitOptions.RemoveEmptyEntries); var sort1 = sorts.Length > 0 ? sorts[0] : ""; var direction1 = directions.Length > 0 ? directions[0] : ""; switch (sort1) { case "itemID": if (direction1 == "up") { items = items.OrderBy(x => x.itemID); } else { items = items.OrderByDescending(x => x.itemID); } break; case "created": if (direction1 == "up") { items = items.OrderBy(x => x.created); } else { items = items.OrderByDescending(x => x.created); } break; case "createdBy": if (direction1 == "up") { items = items.OrderBy(x => x.createdBy); } else { items = items.OrderByDescending(x => x.createdBy); } break; case "errors": if (direction1 == "up") { items = items.OrderBy(x => x.errors); } else { items = items.OrderByDescending(x => x.errors); } break; case "info": if (direction1 == "up") { items = items.OrderBy(x => x.info); } else { items = items.OrderByDescending(x => x.info); } break; case "durationSec": if (direction1 == "up") { items = items.OrderBy(x => x.durationSec); } else { items = items.OrderByDescending(x => x.durationSec); } break; case "withBackup": if (direction1 == "up") { items = items.OrderBy(x => x.withBackup); } else { items = items.OrderByDescending(x => x.withBackup); } break; case "isImport": if (direction1 == "up") { items = items.OrderBy(x => x.isImport); } else { items = items.OrderByDescending(x => x.isImport); } break; default: if (direction1 == "up") { items = items.OrderBy(x => x.created); } else { items = items.OrderByDescending(x => x.created); } break; } var total = items.Count(); var res = items.Skip(parameters.pageSize * (parameters.page - 1)).Take(parameters.pageSize).ToList(); return(Json(new { items = res.Select(x => new { x.id, itemName = x.imp_items.name, x.itemID, created = x.created.GetValueOrDefault().ToString("dd.MM.yyyy"), x.createdBy, x.errors, x.info, x.durationSec, withBackup = (x.withBackup == true) ? "Да" : "Нет", isImport = (x.isImport == true) ? "Да" : "Нет" }), total = items.Count() }, JsonRequestBehavior.AllowGet)); }
public async Task<HttpResponseMessage> Post() { AjaxModel<string> ajax = new AjaxModel<string>() { Success = true, Message = PosMessage.UserSaveSuccessful, Model = PosMessage.Blank }; try { string root = HttpContext.Current.Server.MapPath("~/Data"); var provider = new MultipartFormDataStreamProvider(root); await Request.Content.ReadAsMultipartAsync(provider); //getting the user details UserModel model = new UserModel(); model.UserID = Convert.ToInt32(provider.FormData["UserID"]); model.FirstName = provider.FormData["FirstName"]; model.LastName = provider.FormData["LastName"]; model.UserName = provider.FormData["UserName"]; model.Password = provider.FormData["Password"]; model.PhotoUrl = provider.FormData["PhotoUrl"]; model.PhotoUrl = model.PhotoUrl == "" ? null : model.PhotoUrl; //checking whether the user exists if (PosRepository.UserExists(model)) { ajax.Success = false; ajax.Message = PosMessage.UserNameExists; } else { if (provider.FileData.Count > 0) { MultipartFileData fileData = provider.FileData[0]; FileInfo fi = new FileInfo(fileData.LocalFileName); //getting the file saving path string clientFileName = fileData.Headers.ContentDisposition.FileName.Replace(@"""", ""); if (clientFileName != "") { string clientExtension = clientFileName.Substring(clientFileName.LastIndexOf('.')); string serverFileName = fi.DirectoryName + @"\" + model.UserName + clientExtension; model.PhotoUrl = model.UserName; FileInfo fiOld = new FileInfo(serverFileName); if (fiOld.Exists) fiOld.Delete(); //if (File.Exists()) fi.MoveTo(serverFileName); } else { if (fi.Exists) fi.Delete(); } } PosRepository.UserSave(model); } } catch (Exception exp) { ajax.Success = false; ajax.Message = exp.Message; } return Request.CreateResponse(HttpStatusCode.OK, ajax, "application/json"); ; }
public async void MaterialViewModelGet() { // Arrange this.QuarryDbContext.MaterialColours.AddRange( new MaterialColourEntity() { MaterialColourId = 1, ColourName = "White", CompanyId = 1, DeletedInd = false }, new MaterialColourEntity() { MaterialColourId = 2, ColourName = "Smoky", CompanyId = 1, DeletedInd = false }); this.QuarryDbContext.ProductTypes.AddRange( new ProductTypeEntity() { ProductTypeId = 1, ProductTypeName = "Slab", CompanyId = 1, DeletedInd = false }, new ProductTypeEntity() { ProductTypeId = 2, ProductTypeName = "Tile", CompanyId = 1, DeletedInd = false }); this.QuarryDbContext.Quarries.AddRange( new QuarryEntity() { QuarryId = 1, QuarryName = "QM1", CompanyId = 1, DeletedInd = false }, new QuarryEntity() { QuarryId = 2, QuarryName = "QM2", CompanyId = 1, DeletedInd = false }); this.QuarryDbContext.Textures.AddRange( new TextureEntity() { TextureId = 1, TextureName = "Crystaline", CompanyId = 1, DeletedInd = false }, new TextureEntity() { TextureId = 2, TextureName = "Milky", CompanyId = 1, DeletedInd = false }); this.QuarryDbContext.ProcessTypes.AddRange( new ProcessTypeEntity() { ProcessTypeId = 1, ProcessTypeName = "Cutting", CompanyId = 1, DeletedInd = false }, new ProcessTypeEntity() { ProcessTypeId = 2, ProcessTypeName = "Crushing", CompanyId = 1, DeletedInd = false }); await this.SaveChangesAsync(this.QuarryDbContext); // Act AjaxModel <MaterialViewModel> ajaxModel = await this.Controller.MaterialViewModelGet(); MaterialViewModel viewModel = ajaxModel.Model; // Assert Assert.Equal(viewModel.MaterialColours[1].Item, "White"); Assert.Equal(viewModel.ProductTypes[1].ProductTypeName, "Tile"); Assert.Equal(viewModel.Quarries[1].Item, "QM2"); Assert.Equal(viewModel.Textures[1].Item, "Milky"); Assert.Equal(viewModel.ProcessTypes[1].Item, "Cutting"); }