예제 #1
0
        public IHttpActionResult Post(TeamPageModel model)
        {
            if (!ModelState.IsValid || model == null)
            {
                return(Response(new { Success = false, Message = "Invalid data" }));
            }

            var teamPage = new TeamPage
            {
                Description   = model.Description,
                Name          = model.Name,
                TeamPictureId = model.TeamPictureId,
                CreatedBy     = ApplicationContext.Current.CurrentUser.Id,
                CreatedOn     = DateTime.UtcNow,
                UpdatedOn     = DateTime.UtcNow
            };

            //save to db now
            _teamPageService.Insert(teamPage);

            return(RespondSuccess(new
            {
                TeamPage = teamPage.ToModel(_mediaService)
            }));
        }
예제 #2
0
        public IHttpActionResult Post(TeamPageModel model)
        {
            if (!ModelState.IsValid || model == null)
            {
                return(Response(new { Success = false, Message = "Invalid data" }));
            }

            var teamPage = Mapper.Map <TeamPage>(model);

            teamPage.CreatedBy = _workContext.CurrentCustomer.Id;
            teamPage.CreatedOn = DateTime.UtcNow;
            teamPage.UpdatedOn = DateTime.UtcNow;
            //save to db now
            _teamPageService.Insert(teamPage);

            return(Response(new
            {
                Success = true,
                Url = Url.RouteUrl("TeamPage", new RouteValueDictionary()
                {
                    { "TeamId", teamPage.Id }
                })
            }));
        }