public void Delete(ReasonDto item) { var entity = _mapper.Map <ReasonDto, Reason>(item); _dbContext.Set <Reason>().Remove(entity); _dbContext.SaveChanges(); }
private Reason GetReason(ReasonDto dto) { var reason = _pool.Pop <Reason>(); reason.Id = dto.Id; reason.Name.text = dto.Name; return(reason); }
void EventAggHub <OpenReasonInfo, ReasonDto> .ISubscribed.OnEvent(ReasonDto value) { var data = new Dictionary <string, object> { { "Reason", value } }; WindowHandler.OpenWindow(WindowType.ReasonInfo, data); }
//Maps A ReasonDto Object to a Reason Object //Takes a ReasonDto Object as a parameter //Returns A Reason private Reason MapDtoToReason(ReasonDto reason) { return(new Reason() { Color = reason.Color, Content = reason.Content, DateCreated = reason.DateCreated }); }
public async Task <ActionResult> AddReason(ReasonDto reason) { var reasontoAdd = MapDtoToReason(reason); //Maps the Dto from the parameter to a Reason Object await _context.AddAsync(reasontoAdd); //Adds the Reason to the Database await _context.SaveChangesAsync(); //Saves Changes return(Ok("Reason Successfully Added")); //Returns a 200 Status Code with a success message }
private void OpenReasonWindow(ReasonDto reason) { var data = new Dictionary <string, object> { { "GoDownReason", reason } }; WindowHandler.OpenWindow(UiScenario.Concrete.Data.WindowType.SendDown, data); }
public ReasonDto Update(ReasonDto item) { var entity = _mapper.Map <ReasonDto, Reason>(item); _dbContext.Entry(entity).State = EntityState.Modified; _dbContext.SaveChanges(); var savedItem = _mapper.Map <Reason, ReasonDto>(entity); return(savedItem); }
public ReasonDto Insert(ReasonDto item) { var entity = _mapper.Map <ReasonDto, Reason>(item); _dbContext.Set <Reason>().Add(entity); _dbContext.SaveChanges(); var savedItem = _mapper.Map <Reason, ReasonDto>(entity); return(savedItem); }
public ActionResult <ApiResponse <int> > SendMail(int id, StudentMailDto emailDto) { var response = new ApiResponse <int>(); try { StudentProfileDto student = _mapper.Map <StudentProfileDto>(_studentRepository.Profile(id)); ReasonDto reasonDto = _mapper.Map <ReasonDto>(_reasonRepository.Find(r => r.Id == emailDto.ReasonId)); if (student != null && reasonDto != null) { StreamReader reader = new StreamReader(Path.GetFullPath("Templates/Email.html")); string body = string.Empty; body = reader.ReadToEnd(); //body = body.Replace("{username}", emailDto.Body); body = body.Replace("{username}", "Enviado por, " + student.User.Name + " " + student.User.LastName + " " + student.User.MotherName); body = body.Replace("{pass}", emailDto.Body); Email email = new Email(); email.To = reasonDto.Target; email.Subject = reasonDto.Title; email.Body = body; email.IsBodyHtml = true; _emailService.SendEmail(email); response.Message = "El correo se ha enviado correctamente"; response.Result = id; } else { response.Success = false; response.Message = "Hubo un error, intenta mas tarde"; } } catch (Exception ex) { response.Result = 0; response.Success = false; response.Message = "Internal server error"; _logger.LogError($"Something went wrong: { ex.ToString() }"); return(StatusCode(500, response)); } return(Ok(response)); }
public void save(ReasonDto ReasonDto, Login userLogin) { var dbReason = Mapper.Map<MST_REASON>(ReasonDto); _ReasonBLL.save(dbReason, userLogin); }
public void save(ReasonDto ReasonDto) { var dbReason = Mapper.Map<MST_REASON>(ReasonDto); _ReasonBLL.save(dbReason); }
public override void Open(Dictionary <string, object> callData) { _reason = (ReasonDto)callData["GoDownReason"]; ShowData(_reason.Name, _reason.Description); }
public IHttpActionResult Put([FromUri] int id, [FromBody] ReasonDto updatedItem) { var item = repo.Update(updatedItem); return(Ok(item)); }
public IHttpActionResult Post([FromBody] ReasonDto newItem) { var item = repo.Insert(newItem); return(Ok(item)); }