public IHttpActionResult CreateUpdateLog(int id, UpdateLogDTO newUpdateLog) { var updateLog = new UpdateLogDTO(); try { // Check authen. if (User.Identity == null || !User.Identity.IsAuthenticated) { return Ok(new HttpMessageDTO { Status = DDLConstants.HttpMessageType.ERROR, Message = "", Type = DDLConstants.HttpMessageType.NOT_AUTHEN }); } if (!ModelState.IsValid) { return Ok(new HttpMessageDTO { Status = DDLConstants.HttpMessageType.ERROR, Message = "", Type = DDLConstants.HttpMessageType.BAD_REQUEST }); } updateLog = ProjectRepository.Instance.CreateUpdateLog(id, newUpdateLog, User.Identity.Name); } catch (KeyNotFoundException) { return Ok(new HttpMessageDTO { Status = DDLConstants.HttpMessageType.ERROR, Message = "", Type = DDLConstants.HttpMessageType.NOT_FOUND }); } catch (NotPermissionException) { return Ok(new HttpMessageDTO { Status = DDLConstants.HttpMessageType.ERROR, Message = "", Type = DDLConstants.HttpMessageType.NOT_AUTHEN }); } catch (Exception) { return Ok(new HttpMessageDTO { Status = DDLConstants.HttpMessageType.ERROR, Message = "", Type = DDLConstants.HttpMessageType.BAD_REQUEST }); } return Ok(new HttpMessageDTO { Status = DDLConstants.HttpMessageType.SUCCESS, Message = "", Type = "", Data = updateLog }); }
public IHttpActionResult EditSingleUpdateLog(UpdateLogDTO updateLog) { var result = new UpdateLogDTO(); try { // Check authen. if (User.Identity == null || !User.Identity.IsAuthenticated) { return Ok(new HttpMessageDTO { Status = DDLConstants.HttpMessageType.ERROR, Message = "", Type = DDLConstants.HttpMessageType.NOT_AUTHEN }); } if (updateLog == null) { return Ok(new HttpMessageDTO { Status = DDLConstants.HttpMessageType.ERROR, Message = "", Type = DDLConstants.HttpMessageType.BAD_REQUEST }); } result = ProjectRepository.Instance.EditSingleUpdateLog(updateLog, User.Identity.Name); } catch (KeyNotFoundException) { return Ok(new HttpMessageDTO { Status = DDLConstants.HttpMessageType.ERROR, Message = "", Type = DDLConstants.HttpMessageType.NOT_FOUND }); } catch (NotPermissionException) { return Ok(new HttpMessageDTO { Status = DDLConstants.HttpMessageType.ERROR, Message = "", Type = DDLConstants.HttpMessageType.NOT_AUTHEN }); } catch (Exception) { return Ok(new HttpMessageDTO { Status = DDLConstants.HttpMessageType.ERROR, Message = "", Type = DDLConstants.HttpMessageType.BAD_REQUEST }); } return Ok(new HttpMessageDTO { Status = DDLConstants.HttpMessageType.SUCCESS, Message = "", Type = "", Data = result }); }