public IHttpActionResult Put(TeamPageModel model) { if (!ModelState.IsValid || model == null || model.Id == 0) { return(Response(new { Success = false, Message = "Invalid data" })); } var teamPage = _teamPageService.Get(model.Id); //check if the page exists or not & the person editing actually owns the resource if (teamPage.CreatedBy != ApplicationContext.Current.CurrentUser.Id && !ApplicationContext.Current.CurrentUser.IsAdministrator()) { return(Response(new { Success = false, Message = "Unauthorized" })); } teamPage.Description = model.Description; teamPage.Name = model.Name; teamPage.TeamPictureId = model.TeamPictureId; //update the updation date teamPage.UpdatedOn = DateTime.UtcNow; //update now _teamPageService.Update(teamPage); return(RespondSuccess(new { TeamPage = teamPage.ToModel(_mediaService) })); }
public IHttpActionResult Put(TeamPageModel model) { if (!ModelState.IsValid || model == null || model.Id == 0) { return(Response(new { Success = false, Message = "Invalid data" })); } var teamPage = _teamPageService.GetById(model.Id); //check if the page exists or not & the person editing actually owns the resource if (teamPage.CreatedBy != _workContext.CurrentCustomer.Id && !_workContext.CurrentCustomer.IsAdmin()) { return(Response(new { Success = false, Message = "Unauthorized" })); } Mapper.Map(model, teamPage); //update the updation date teamPage.UpdatedOn = DateTime.UtcNow; //update now _teamPageService.Update(teamPage); return(Response(new { Success = true })); }