public async Task <IActionResult> PutStatusEmailType([FromRoute] long id, [FromBody] StatusEmailType statusEmailType) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != statusEmailType.idStatusEmailType) { return(BadRequest()); } _context.Entry(statusEmailType).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StatusEmailTypeExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PostStatusEmailType([FromBody] StatusEmailType statusEmailType) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.StatusEmailType.Add(statusEmailType); await _context.SaveChangesAsync(); return(CreatedAtAction("GetStatusEmailType", new { id = statusEmailType.idStatusEmailType }, statusEmailType)); }
private Alert AlertPool(Pool p) { Alert r = new Alert(); r.Content = false; if (p.idPool != 6) { int statusIdP = p.idStatus; int poolIdP = p.idPool + 1; //StatusEmailType sEType = this._context.GetEmailTypeStatus(statusIdP); //StatusEmailType sEType = (StatusEmailType)this._context.Pool.FromSql($"[Pool].[GetEmailTypeStatus] {statusIdP}"); StatusEmailType sEType = this.GetEmailTypeStatus(statusIdP); if (sEType != null) { //var pPool = this._context.GetPoolByIdUnique(poolIdP); //var pPool = (Pool)this._context.Pool.FromSql($"[Pool].[GetPoolById] {poolIdP}").FirstOrDefault(); var pPool = this.GetPoolByIdUnique(poolIdP); if (pPool != null) { if (sEType.idStatusNextPool == pPool.idStatus) { //var emailType = _context.GetEmailType(sEType.idEmailType.Value); //var emailType = (EmailType)this._context.Pool.FromSql($"[Pool].[GetEmailType] {sEType.idEmailType.Value}"); var emailType = GetEmailType(sEType.idEmailType.Value); if (emailType != null && emailType.idEmailType != 0) { r.Title = emailType.EmailSubject; string body = String.Format(emailType.EmailBody, p.Identification, pPool.Identification); r.Message = r.Message + " " + body + ". "; r.Content = true; } //fin if (emailType != null) } } } } if (p.idPool != 1) { int statusIdP = p.idStatus; int poolIdP = p.idPool - 1; //StatusEmailType sEType = this._context.GetEmailTypeStatus(statusIdP); //StatusEmailType sEType = (StatusEmailType)this._context.Pool.FromSql($"[Pool].[GetEmailTypeStatus] {statusIdP}"); StatusEmailType sEType = this.GetEmailTypeStatus(statusIdP); if (sEType != null) { //var pPool = this._context.GetPoolByIdUnique(poolIdP); //var pPool = (Pool)this._context.Pool.FromSql($"[Pool].[GetPoolById] {poolIdP}").FirstOrDefault(); var pPool = this.GetPoolByIdUnique(poolIdP); if (pPool != null) { if (sEType.idStatusNextPool == pPool.idStatus) { //var emailType = _context.GetEmailType(sEType.idEmailType.Value); //var emailType = (EmailType)this._context.Pool.FromSql($"[Pool].[GetEmailType] {sEType.idEmailType.Value}"); var emailType = GetEmailType(sEType.idEmailType.Value); if (emailType != null && emailType.idEmailType != 0) { r.Title = emailType.EmailSubject; string body = String.Format(emailType.EmailBody, p.Identification, pPool.Identification); r.Message = r.Message + " " + body + ". "; r.Content = true; } //fin if (emailType != null) } } } } return(r); }