public Task <int> InsertAsync(NotificationTypeVM entity) { return(Task.Run <int>(() => { var dbEntity = Mapper.Map <NotificationTypeVM, NotificationType>(entity); dbEntity.AddedOn = DateTime.Now; dbEntity.Active = true; dbEntity.Position = 1; var returnedObject = _NotificationTypeRepo.Add(dbEntity); return returnedObject.ID; })); }
public Task <bool> UpdateAsync(NotificationTypeVM entity) { return(Task.Run <bool>(async() => { var dbEntity = await getById(entity.ID); if (dbEntity != null) { var mappedEntity = Mapper.Map(entity, dbEntity); mappedEntity.UpdatedOn = DateTime.Now; _NotificationTypeRepo.Update(mappedEntity, mappedEntity.ID); return true; } else { return false; } })); }
public async Task <HttpResponseMessage> edit([FromBody] NotificationTypeVM entity) { var state = await _typeService.UpdateAsync(entity); return(Request.CreateResponse(HttpStatusCode.OK, state, Configuration.Formatters.JsonFormatter)); }
public async Task <HttpResponseMessage> add([FromBody] NotificationTypeVM entity) { var id = await _typeService.InsertAsync(entity); return(Request.CreateResponse(HttpStatusCode.OK, id, Configuration.Formatters.JsonFormatter)); }