// // GET: /ConditionTemplate/Delete/5 public ActionResult Delete(int id) { IRepository <Models.Condition> repo = new ConditionRepository(); repo.Delete(repo.GetById(id)); return(RedirectToAction("Index")); }
public JsonResult AddUpdateCondition(long conditionID, PatientConditions_Custom condition) { try { if (condition.conditionName == null || condition.conditionName == "" || !Regex.IsMatch(condition.conditionName, "^[0-9a-zA-Z ]+$")) { ApiResultModel apiresult = new ApiResultModel(); apiresult.message = "Invalid condition name.Only letters and numbers are allowed."; return(Json(new { Success = true, ApiResultModel = apiresult })); } ConditionRepository objRepo = new ConditionRepository(); if (conditionID == 0) { ApiResultModel apiresult = new ApiResultModel(); apiresult = objRepo.AddCondition(condition); return(Json(new { Success = true, ApiResultModel = apiresult })); } else { ApiResultModel apiresult = objRepo.EditCondition(conditionID, condition); return(Json(new { Success = true, ApiResultModel = apiresult })); } } catch (Exception ex) { return(Json(new { Message = ex.Message })); } }
public RetrieveAllPagedResultOutput <ConditionDto, long> RetrieveAllPagedResult( RetrieveAllConditionsPagedResultInput input) { ConditionRepository.Includes.Add(r => r.LastModifierUser); ConditionRepository.Includes.Add(r => r.CreatorUser); ConditionRepository.Includes.Add(r => r.ConditionType); IQueryable <Condition> conditionsQuery = ConditionPolicy.CanRetrieveManyEntities( ConditionRepository.GetAll() .WhereIf(!input.ConditionIds.IsNullOrEmpty(), r => input.ConditionIds.Contains(r.Id)) .WhereIf(!String.IsNullOrEmpty(input.Name), r => r.Name.ToLower().Contains(input.Name.ToLower()))) .OrderBy(r => r.Order); int totalCount = conditionsQuery.Count(); IReadOnlyList <ConditionDto> conditionDtos = conditionsQuery .OrderBy(r => r.Name) .Skip(input.SkipCount).Take(input.MaxResultCount) .ToList().MapIList <Condition, ConditionDto>().ToList(); ConditionRepository.Includes.Clear(); return(new RetrieveAllPagedResultOutput <ConditionDto, long>() { Items = conditionDtos, TotalCount = totalCount }); }
public UpdateOutput <ConditionDto, long> Update(UpdateInput <ConditionDto, long> input) { throw new NotSupportedException("This method is implemented but it is not safely to use it."); Condition newConditionEntity = input.Entity.MapTo <Condition>(); if (newConditionEntity == null) { throw new CityQuestItemNotFoundException(CityQuestConsts.CityQuestItemNotFoundExceptionMessageBody, "\"Condition\""); } if (!ConditionPolicy.CanUpdateEntity(newConditionEntity)) { throw new CityQuestPolicyException(CityQuestConsts.CQPolicyExceptionUpdateDenied, "\"Condition\""); } ConditionRepository.Includes.Add(r => r.LastModifierUser); ConditionRepository.Includes.Add(r => r.CreatorUser); ConditionRepository.Includes.Add(r => r.ConditionType); ConditionRepository.Update(newConditionEntity); ConditionDto newConditionDto = (ConditionRepository.Get(newConditionEntity.Id)).MapTo <ConditionDto>(); ConditionRepository.Includes.Clear(); return(new UpdateOutput <ConditionDto, long>() { UpdatedEntity = newConditionDto }); }
public RetrieveOutput <ConditionDto, long> Retrieve(RetrieveConditionInput input) { ConditionRepository.Includes.Add(r => r.LastModifierUser); ConditionRepository.Includes.Add(r => r.CreatorUser); ConditionRepository.Includes.Add(r => r.ConditionType); IList <Condition> conditionEntities = ConditionRepository.GetAll() .WhereIf(input.Id != null, r => r.Id == input.Id) .WhereIf(!String.IsNullOrEmpty(input.Name), r => r.Name.ToLower().Contains(input.Name.ToLower())) .ToList(); if (conditionEntities.Count != 1) { throw new CityQuestItemNotFoundException(CityQuestConsts.CityQuestItemNotFoundExceptionMessageBody, "\"Condition\""); } if (!ConditionPolicy.CanRetrieveEntity(conditionEntities.Single())) { throw new CityQuestPolicyException(CityQuestConsts.CQPolicyExceptionRetrieveDenied, "\"Condition\""); } ConditionDto conditionEntity = conditionEntities.Single().MapTo <ConditionDto>(); ConditionRepository.Includes.Clear(); return(new RetrieveOutput <ConditionDto, long>() { RetrievedEntity = conditionEntity }); }
/// <summary> /// Default Constructor /// </summary> public ConditionListModel() { if (_conditionRepository == null) { _conditionRepository = new ConditionRepository(); } AllConditions = new ObservableCollection <Condition>(_conditionRepository.GetConditions()); _conditionList = new ObservableCollection <Condition>(_conditionRepository.GetConditions()); }
private Condition UpdateConditionEntity(Condition existCondition, ConditionDto newCondition) { existCondition.Description = newCondition.Description; existCondition.ConditionTypeId = newCondition.ConditionTypeId; existCondition.Name = newCondition.Name; existCondition.Order = newCondition.Order; existCondition.Points = newCondition.Points; existCondition.ValueToPass = newCondition.ValueToPass; return(ConditionRepository.Update(existCondition)); }
public TryToPassConditionOutput TryToPassCondition(TryToPassConditionInput input) { bool result = false; #region Retrieving current player career UserRepository.Includes.Add(r => r.PlayerCareers); UserRepository.Includes.Add(r => r.PlayerCareers.Select(e => e.Team.PlayerCareers)); PlayerCareer currCareer = UserRepository.Get(Session.UserId ?? 0) .PlayerCareers.Where(r => r.CareerDateEnd == null).SingleOrDefault(); UserRepository.Includes.Clear(); #endregion if (currCareer != null) { #region Retrieving current condition ConditionRepository.Includes.Add(r => r.GameTask.Game); ConditionRepository.Includes.Add(r => r.ConditionType); Condition currentCondition = ConditionRepository.Get(input.ConditionId); if (currentCondition == null || currentCondition.GameTask == null || currentCondition.GameTask.Game == null || !GamePolicy.CanRetrieveEntityLight(currentCondition.GameTask.Game)) { //throw new CityQuestPolicyException(CityQuestConsts.CQPolicyExceptionRetrieveDenied, "\"Game\""); return(new TryToPassConditionOutput() { Result = result }); } ConditionRepository.Includes.Clear(); #endregion IList <long> teamPlayerCareerIds = currCareer.Team.PlayerCareers.Select(e => e.Id).ToList(); bool alreadyPassedThisCondition = TeamGameTaskStatisticRepository.GetAll() .Where(r => r.TeamId == currCareer.TeamId && r.GameTaskId == currentCondition.GameTaskId).Count() != 0 || PlayerGameTaskStatisticRepository.GetAll() .Where(r => teamPlayerCareerIds.Contains(r.PlayerCareerId) && r.GameTaskId == currentCondition.GameTaskId).Count() != 0; if (!alreadyPassedThisCondition) { result = HandleAttempt(currentCondition, currCareer, input.Value); } } return(new TryToPassConditionOutput() { Result = result }); }
// GET: api/Conditions?location=paris public string Get(string location, string days) { WeatherRepository weatherRepo = new WeatherRepository(); WeatherModel weather = weatherRepo.GetWeatherData(location, days); ConditionRepository conditionRepo = new ConditionRepository(); ConditionModel condition = conditionRepo.Map(weather); JavaScriptSerializer serializer = new JavaScriptSerializer(); return(serializer.Serialize(condition)); }
public RetrieveAllConditionsLikeComboBoxesOutput RetrieveAllConditionsLikeComboBoxes( RetrieveAllConditionsLikeComboBoxesInput input) { IReadOnlyList <ComboboxItemDto> conditionsLikeComboBoxes = ConditionPolicy.CanRetrieveManyEntities( ConditionRepository.GetAll()).ToList().OrderBy(r => r.Order) .Select(r => new ComboboxItemDto(r.Id.ToString(), r.Name)).ToList(); return(new RetrieveAllConditionsLikeComboBoxesOutput() { Items = conditionsLikeComboBoxes }); }
public ActionResult Delete(int id, FormCollection collection) { try { IRepository <Models.Condition> repo = new ConditionRepository(); repo.Delete(repo.GetById(id)); return(RedirectToAction("Index")); } catch { return(View()); } }
public JsonResult DeleteCondition(long conditionID) { try { ConditionRepository objRepo = new ConditionRepository(); ApiResultModel apiresult = new ApiResultModel(); apiresult = objRepo.DeleteCondition(conditionID); return(Json(new { Success = true, ApiResultModel = apiresult })); } catch (Exception ex) { return(Json(new { Message = ex.Message })); } }
public JsonResult GetHealthConditions(long patientid) { try { ConditionRepository objRepo = new ConditionRepository(); List <GetPatientConditions> model = objRepo.LoadHealthConditions(patientid); return(Json(new { Success = true, Conditions = model })); } catch (Exception ex) { return(Json(new { Message = ex.Message })); } }
public ManageProductGroupDependencyController(UsersAccessRepository usersAccessRepository, ProductGroupDependenciesRepository productGroupDependenciesRepository, ProductGroupRepository productGroupRepository, FeatureRepository featureRepository, ConditionRepository conditionRepository, ProductGroupFeatureRepository productGroupFeatureRepository, FeatureItemRepository featureItemRepository ) : base(usersAccessRepository) { _productGroupDependenciesRepository = productGroupDependenciesRepository; _productGroupRepository = productGroupRepository; _featureRepository = featureRepository; _conditionRepository = conditionRepository; _productGroupFeatureRepository = productGroupFeatureRepository; _featureItemRepository = featureItemRepository; }
private void UpdateGameTaskEntityRelations(GameTask existGameTask, GameTaskDto newGameTask) { #region Updating Conditions IList <Condition> conditionsForDelete = existGameTask.Conditions.ToList(); foreach (ConditionDto newCondition in newGameTask.Conditions) { if (newCondition.Id > 0) { Condition existCondition = existGameTask.Conditions.First(r => r.Id == newCondition.Id); conditionsForDelete.Remove(existCondition); UpdateConditionEntity(existCondition, newCondition); } else { ConditionRepository.Insert(newCondition.MapTo <Condition>()); } } ConditionRepository.RemoveRange(conditionsForDelete); #endregion #region Updating Tips IList <Tip> tipsForDelete = existGameTask.Tips.ToList(); foreach (TipDto newTip in newGameTask.Tips) { if (newTip.Id > 0) { Tip existTip = existGameTask.Tips.First(r => r.Id == newTip.Id); tipsForDelete.Remove(existTip); UpdateTipEntity(existTip, newTip); } else { TipRepository.Insert(newTip.MapTo <Tip>()); } } TipRepository.RemoveRange(tipsForDelete); #endregion }
public ActionResult Create(FormCollection collection) { try { // TODO: Add insert logic here string name = collection.Get("Name"); Condition condition = new Condition() { Name = name }; IRepository <Condition> repo = new ConditionRepository(); repo.Save(condition); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Edit(int id, FormCollection collection) { try { // TODO: Add update logic here string name = collection.Get("Name"); Condition condition = new Condition() { ID = id, Name = name }; IRepository <Condition> repo = new ConditionRepository(); repo.Update(condition); return(RedirectToAction("Index")); } catch { return(View()); } }
public RetrieveAllOutput <ConditionDto, long> RetrieveAll(RetrieveAllConditionInput input) { ConditionRepository.Includes.Add(r => r.LastModifierUser); ConditionRepository.Includes.Add(r => r.CreatorUser); ConditionRepository.Includes.Add(r => r.ConditionType); IList <Condition> conditionEntities = ConditionPolicy.CanRetrieveManyEntities( ConditionRepository.GetAll() .WhereIf(!input.ConditionIds.IsNullOrEmpty(), r => input.ConditionIds.Contains(r.Id)) .WhereIf(!String.IsNullOrEmpty(input.Name), r => r.Name.ToLower().Contains(input.Name.ToLower()))) .OrderBy(r => r.Order) .ToList(); IList <ConditionDto> result = conditionEntities.MapIList <Condition, ConditionDto>(); ConditionRepository.Includes.Clear(); return(new RetrieveAllOutput <ConditionDto, long>() { RetrievedEntities = result }); }
public DeleteOutput <long> Delete(DeleteInput <long> input) { throw new NotSupportedException("This method is implemented but it is not safely to use it."); Condition conditionEntityForDelete = ConditionRepository.Get(input.EntityId); if (conditionEntityForDelete == null) { throw new CityQuestItemNotFoundException(CityQuestConsts.CityQuestItemNotFoundExceptionMessageBody, "\"Condition\""); } if (!ConditionPolicy.CanDeleteEntity(conditionEntityForDelete)) { throw new CityQuestPolicyException(CityQuestConsts.CQPolicyExceptionDeleteDenied, "\"Condition\""); } ConditionRepository.Delete(conditionEntityForDelete); return(new DeleteOutput <long>() { DeletedEntityId = input.EntityId }); }
public CreateOutput <ConditionDto, long> Create(CreateInput <ConditionDto, long> input) { throw new NotSupportedException("This method is implemented but it is not safely to use it."); Condition newConditionEntity = input.Entity.MapTo <Condition>(); if (!ConditionPolicy.CanCreateEntity(newConditionEntity)) { throw new CityQuestPolicyException(CityQuestConsts.CQPolicyExceptionCreateDenied, "\"Condition\""); } ConditionRepository.Includes.Add(r => r.LastModifierUser); ConditionRepository.Includes.Add(r => r.CreatorUser); ConditionRepository.Includes.Add(r => r.ConditionType); ConditionDto newConditionDto = (ConditionRepository.Insert(newConditionEntity)).MapTo <ConditionDto>(); ConditionRepository.Includes.Clear(); return(new CreateOutput <ConditionDto, long>() { CreatedEntity = newConditionDto }); }
// // GET: /ConditionTemplate/Edit/5 public ActionResult Edit(int id) { IRepository <Condition> repo = new ConditionRepository(); return(View(repo.GetById(id))); }
// // GET: /ConditionTemplate/ public ActionResult Index() { IRepository <Models.Condition> repo = new ConditionRepository(); return(View(repo.GetAll())); }
public PostVisitCareController() { _vetRepo = new VetRepository(new FnRDbContext()); _conditionRepo = new ConditionRepository(new FnRDbContext()); _userRepo = new UserRepository(new FnRDbContext()); }
public ManageConditionController(UsersAccessRepository usersAccessRepository, ConditionRepository conditionRepository) : base(usersAccessRepository) { _conditionRepository = conditionRepository; }