Exemplo n.º 1
0
		public ActionResult Delete(int? id, bool? saveChangesError = false)
		{
			if (id == null)
			{
				return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
			}
			if (saveChangesError.GetValueOrDefault())
			{
				ViewBag.ErrorMessage = "Delete failed. Try again, and if the problem persists see your system administrator.";
			}

			UserProfileDTO userProfileDTO = _userProfileService.GetUserProfile(id);

			if (userProfileDTO == null)
			{
				return HttpNotFound();
			}

			var userProfile = _mapper.Map<UserProfileDTO, UserProfileViewModel>(userProfileDTO);

			DirectionDTO directionDTO = _directionService.GetDirection(userProfileDTO.DirectionId);
			var direction = _mapper.Map<DirectionDTO, DirectionViewModel>(directionDTO);

			ViewBag.Direction = direction.Name;

			return View(userProfile);
		}
Exemplo n.º 2
0
        public void AddDirection(ILocation Location, Object callback = null, bool CopyToAction = false)
        {
            String       id          = null;
            CallbackDTO  cdo         = new CallbackDTO();
            PropertyInfo Name        = null;
            PropertyInfo Description = null;

            if (callback != null)
            {
                Description = callback.GetType().GetProperty("Description");
                var t = callback.GetType().GetProperty("t");
                var c = callback.GetType().GetProperty("c");
                Name = callback.GetType().GetProperty("Name");

                if (c != null)
                {
                    id               = Guid.NewGuid().ToString("N");
                    cdo.c            = (Action)c.GetValue(callback, null);
                    cdo.Scene        = Location.Scene;
                    cdo.CurrentScene = data.CurrentScene;
                }
                if (t != null)
                {
                    id               = Guid.NewGuid().ToString("N");
                    cdo.t            = Convert.ToInt32(t.GetValue(callback, null).ToString());
                    cdo.Scene        = Location.Scene;
                    cdo.CurrentScene = data.CurrentScene;
                }
                if (id != null)
                {
                    sc.Callbacks.Add(id, cdo);
                }
            }

            DirectionDTO ddt = new DirectionDTO()
            {
                id          = id,
                Name        = (Name != null) ? Name.GetValue(callback, null).ToString() : Location.Name,
                Description = (Description != null) ? Description.GetValue(callback, null).ToString() : Location.Description,
                Scene       = Location.Scene
            };

            sc.Directions.Add(ddt);
            if (CopyToAction)
            {
                ActionDTO adto = new ActionDTO()
                {
                    id          = id,
                    Name        = (Name != null) ? Name.GetValue(callback, null).ToString() : Location.Name,
                    Description = (Description != null) ? Description.GetValue(callback, null).ToString() : Location.Description,
                    Scene       = Location.Scene
                };
                sc.Actions.Add(adto);
            }
        }
Exemplo n.º 3
0
        public void Update(DirectionDTO direction)
        {
            var _direction = Database.Directions.GetById(direction.DirectionId);

            if (_direction != null)
            {
                _mapper.Map(direction, _direction);

                Database.Save();
            }
        }
Exemplo n.º 4
0
        public void Save(DirectionDTO direction)
        {
            var _direction = new Direction
            {
                Name         = direction.Name,
                Description  = direction.Description,
                UserProfiles = _mapper.Map <List <UserProfileDTO>, ICollection <UserProfile> >(direction.UserProfiles.ToList())
            };

            Database.Directions.Create(_direction);

            Database.Save();
        }
Exemplo n.º 5
0
		public ActionResult Details(int? id)
		{
			if (id == null)
			{
				return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
			}

			UserProfileDTO userProfileDTO = _userProfileService.GetUserProfile(id);

			if (userProfileDTO == null)
			{
				return HttpNotFound();
			}

			var userProfile = _mapper.Map<UserProfileDTO, UserProfileViewModel>(userProfileDTO);

			DirectionDTO directionDTO = _directionService.GetDirection(userProfileDTO.DirectionId);
			var direction = _mapper.Map<DirectionDTO, DirectionViewModel>(directionDTO);

			ViewBag.Direction = direction.Name;

			return View(userProfile);
		}