public async Task <bool> Update(int id, UpdateHolidayDto updatedHoliday) { if (updatedHoliday is null) { throw new ArgumentNullException(nameof(updatedHoliday)); } var itemToUpdate = await _holidaysRepository.GetById(id); if (itemToUpdate is null) { return(false); } _mapper.Map(updatedHoliday, itemToUpdate); return(await _holidaysRepository.Update(itemToUpdate)); }
public object Put(Holiday updated) { object json; try { string messageError = ""; Holiday putting = repository.Update(updated, ref messageError); if (putting != null) { json = new { total = 1, data = putting, success = true }; } else { throw new System.InvalidOperationException(messageError); } } catch (Exception ex) { LogManager.Write("ERROR:" + Environment.NewLine + "\tMETHOD = " + this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + Environment.NewLine + "\tMESSAGE = " + ex.Message); json = new { message = ex.Message, success = false }; }; return(json); }