public WorkgroupModel EditWorkgroup(WorkgroupModel model) { try { var edited = _service.EditWorkgroup(model); return(edited); } catch (Exception e) { Console.WriteLine(e); } return(model); }
public IHttpActionResult AddListing(WorkgroupModel model) { try { model.Users = new List <UserModel>(); model.Users.Add(new UserModel { Username = User.Identity.GetUserName() }); _service.AddWorkgroup(model); return(Ok()); } catch (Exception e) { Console.WriteLine(e); } return(InternalServerError()); }
public WorkgroupModel EditWorkgroup(WorkgroupModel group) { var model = Mapper.Map <WorkgroupModel>(group); try { var entry = _context.Workgroups.SingleOrDefault(x => x.Code == model.Code); if (entry != null) { _context.Entry(entry).CurrentValues.SetValues(model); _context.SaveChanges(); return(Mapper.Map <WorkgroupModel>(entry)); } } catch (Exception e) { Console.WriteLine(e); } return(group); }
public WorkgroupModel AddWorkgroup(WorkgroupModel group) { var model = Mapper.Map <Workgroup>(group); try { foreach (var user in group.Users) { var newUser = _context.AspNetUsers.FirstOrDefault(x => x.UserName == user.Username); model.AspNetUsers.Add(newUser); } _context.Workgroups.Add(model); _context.SaveChanges(); return(group); } catch (Exception e) { Console.WriteLine(e); } return(null); }
public WorkgroupModel EditWorkgroup(WorkgroupModel model) { return(_data.EditWorkgroup(model)); }
public WorkgroupModel AddWorkgroup(WorkgroupModel model) { return(_data.AddWorkgroup(model)); }