示例#1
0
        public void Delete(ReasonDto item)
        {
            var entity = _mapper.Map <ReasonDto, Reason>(item);

            _dbContext.Set <Reason>().Remove(entity);
            _dbContext.SaveChanges();
        }
示例#2
0
            private Reason GetReason(ReasonDto dto)
            {
                var reason = _pool.Pop <Reason>();

                reason.Id        = dto.Id;
                reason.Name.text = dto.Name;
                return(reason);
            }
示例#3
0
            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
        }
示例#6
0
        private void OpenReasonWindow(ReasonDto reason)
        {
            var data = new Dictionary <string, object>
            {
                { "GoDownReason", reason }
            };

            WindowHandler.OpenWindow(UiScenario.Concrete.Data.WindowType.SendDown, data);
        }
示例#7
0
        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);
        }
示例#8
0
        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));
        }
示例#10
0
 public void save(ReasonDto ReasonDto, Login userLogin)
 {
     var dbReason = Mapper.Map<MST_REASON>(ReasonDto);
     _ReasonBLL.save(dbReason, userLogin);
 }
示例#11
0
 public void save(ReasonDto ReasonDto)
 {
     var dbReason = Mapper.Map<MST_REASON>(ReasonDto);
     _ReasonBLL.save(dbReason);
 }
示例#12
0
 public override void Open(Dictionary <string, object> callData)
 {
     _reason = (ReasonDto)callData["GoDownReason"];
     ShowData(_reason.Name, _reason.Description);
 }
示例#13
0
        public IHttpActionResult Put([FromUri] int id, [FromBody] ReasonDto updatedItem)
        {
            var item = repo.Update(updatedItem);

            return(Ok(item));
        }
示例#14
0
        public IHttpActionResult Post([FromBody] ReasonDto newItem)
        {
            var item = repo.Insert(newItem);

            return(Ok(item));
        }