Esempio n. 1
0
        public static void InsertPeladaUsers(UnitOfWork unitOfWork, List <User> users, List <Pelada> peladas)
        {
            var peladaUsers = new PeladaUser[]
            {
                new PeladaUser {
                    UserId = users[0].Id, PeladaId = peladas[0].Id, IsMonthly = true, IsAdministrator = true
                },
                new PeladaUser {
                    UserId = users[1].Id, PeladaId = peladas[0].Id, IsMonthly = true, IsAdministrator = true
                },
                new PeladaUser {
                    UserId = users[2].Id, PeladaId = peladas[0].Id
                },
                new PeladaUser {
                    UserId = users[3].Id, PeladaId = peladas[0].Id
                },

                new PeladaUser {
                    UserId = users[0].Id, PeladaId = peladas[1].Id
                },
                new PeladaUser {
                    UserId = users[1].Id, PeladaId = peladas[1].Id
                }
            };

            foreach (var peladaUser in peladaUsers)
            {
                unitOfWork.PeladaUserRepository.Create(peladaUser);
            }
        }
 public PeladaUser Create(PeladaUser obj)
 {
     try
     {
         var newPeladaUser = _unitOfWork.PeladaUserRepository.Create(obj);
         _unitOfWork.Save();
         return(newPeladaUser);
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 3
0
        public JsonResult Post([FromBody] PeladaUser obj)
        {
            try
            {
                var peladaUser = _peladaUserService.Create(obj);

                return(Json(peladaUser));
            }
            catch (System.Exception ex)
            {
                return(Json(ex));
            }
        }
Esempio n. 4
0
        public JsonResult AddUserToPelada([FromRoute] int peladaId, [FromBody] PeladaUser obj)
        {
            try
            {
                obj.PeladaId = peladaId;

                var op            = new CreatePeladaUserOp(_unitOfWork);
                var newPeladaUser = op.Execute(obj);

                var peladaUserViewModel = _mapper.Map <PeladaUserViewModel>(newPeladaUser);

                return(Json(peladaUserViewModel));
            }
            catch (Exception ex)
            {
                return(FormatException(ex));
            }
        }