public void Remove(ProfessionDto item) { var remover = new Remover(this.Session); if (remover.CanRemove(item)) { remover.Remove <Profession>(item); } }
public void IsValid() { var item = new ProfessionDto() { Name = Guid.NewGuid().ToString(), }; Assert.IsTrue(item.IsValid()); }
public void IsInvalid() { var item = new ProfessionDto() { Name = string.Empty, }; Assert.IsFalse(item.IsValid()); }
/// <summary> /// Update profession. /// </summary> /// <param name="profession">New profession data.</param> /// <returns>Service answer that contain success/failure execution and error list of method.</returns> public ServiceAnswer Update(ProfessionDto profession) { var result = new ServiceAnswer(); _logger.Debug("Start update profession method."); try { var isUniqueName = IsUniqueName(profession.Name); if (isUniqueName) { var targetProfession = _professionRepository.FindById(profession.Id); if (targetProfession != null) { _professionRepository.StartTransaction(); targetProfession.Name = profession.Name; _professionRepository.Commit(); result.Status = AnswerStatus.Success; _logger.Info($"Updated profession (id: {profession.Id})."); _logger.Debug("Finish update profession method."); return(result); } result.Status = AnswerStatus.Failure; result.Errors.Add("Finding error", "Profession was not found."); _logger.Warning($"Profession (id: {profession.Id}) was not found."); _logger.Debug("Finish update profession method."); return(result); } result.Status = AnswerStatus.Failure; result.Errors.Add("Updating error", $"Profession with name '{profession.Name}' already exists."); _logger.Warning($"Profession name '{profession.Name}' alredy used."); } catch (Exception exc) { _professionRepository.RollBack(); _logger.Error($"Exception occurred during the updating profession, id: {profession.Id}.\r\n Exception: {exc.ToString()}"); result.Status = AnswerStatus.Failure; result.Errors.Add("Service error", "Some trouble with getting data. Try Later."); } _logger.Debug("Finish update profession method."); return(result); }
/// <summary> /// Creates the specified profession. /// </summary> /// <param name="item">The profession.</param> /// <returns></returns> public long Create(ProfessionDto item) { Assert.IsNotNull(item, "item"); var found = (from p in this.Session.Query <Profession>() where p.Id == item.Id || item.Name.ToLower() == p.Name.ToLower() select p).ToList().Count() > 0; if (found) { throw new ExistingItemException(); } var entity = Mapper.Map <ProfessionDto, Profession>(item); item.Id = (long)this.Session.Save(entity); return(item.Id); }
/// <summary> /// Determines whether this instance can remove the specified item. /// </summary> /// <param name="item">The item.</param> /// <returns> /// <c>true</c> if this instance can remove the specified item; otherwise, <c>false</c>. /// </returns> public bool CanRemove(ProfessionDto item) { return((from t in this.Session.Query <Patient>() where t.Profession.Id == item.Id select t).Count() == 0); }
public static void SetProfession(DependencyObject target, ProfessionDto value) { target.SetValue(ProfessionProperty, value); }
/// <summary> /// Updates the specified profession. /// </summary> /// <param name="profession">The tag.</param> public void Update(ProfessionDto profession) { new Updator(this.Session).Update(profession); }
/// <summary> /// Creates the specified profession. /// </summary> /// <param name="profession">The tag.</param> public long Create(ProfessionDto profession) { return(new Creator(this.Session).Create(profession)); }
public bool CanRemove(ProfessionDto item) { return(new Remover(this.Session).CanRemove(item)); }
public FindPatientByProfessionSpecification(ProfessionDto profession) { this.profession = (profession != null) ? profession.Name.ToLower() : null; }
public Specification <LightPatientDto> ProfessionIs(ProfessionDto profession) { return(new FindPatientByProfessionSpecification(profession)); }
/// <summary> /// Updates the specified profession. /// </summary> /// <param name="profession">The tag.</param> public void Update(ProfessionDto profession) { var entity = Mapper.Map <ProfessionDto, Profession>(profession); this.Session.Update(entity); }