コード例 #1
0
        public async Task <ActionResult <UserViewModel> > AddUser(AddViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }


            if (await _userRepository.CheckEmail(model.Email))
            {
                return(BadRequest("El email ya existe"));
            }



            var resultPass = await _userRepository.CrearPasswordHash(model.Password);

            var user = _mapper.Map <User>(model);

            user.Password_Hash = resultPass.Item1;
            user.Password_Salt = resultPass.Item2;


            var newUser = await _userRepository.AddUser(user);

            if (newUser == null)
            {
                return(BadRequest());
            }

            var newUserResult = _mapper.Map <UserViewModel>(newUser);

            return(CreatedAtAction(nameof(AddUser), new { id = newUserResult.IdUser }, newUserResult));
        }
コード例 #2
0
        public ActionResult Add(string IsSuccess)
        {
            ViewBag.Issuccess = IsSuccess ?? "Empty";
            var model = new AddViewModel();

            return(View(model));
        }
コード例 #3
0
        public IActionResult Add(
            AddViewModel cameraModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(cameraModel));
            }
            if (!cameraModel.LightMetering.Any())
            {
                ModelState.AddModelError(nameof(cameraModel.LightMetering), "Light Metering must have a value!");
                return(View(cameraModel));
            }
            this.cameras.Create(
                cameraModel.Make,
                cameraModel.Model,
                cameraModel.Price,
                cameraModel.Quantity,
                cameraModel.MinShutterSpeed,
                cameraModel.MaxShutterSpeed,
                cameraModel.MinISO,
                cameraModel.MaxISO,
                cameraModel.IsFullFrame,
                cameraModel.VideoResolution,
                cameraModel.LightMetering,
                cameraModel.ImageURL,
                cameraModel.Description,
                this.userManager.GetUserId(User));

            return(RedirectToAction(nameof(HomeController.Index), "Home"));
        }
コード例 #4
0
        public ActionResult Add(AddViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("Add", "Customer", new { message = "Customer not created" }));
            }

            var customer = new Customer
            {
                FirstName          = model.FirstName,
                LastName           = model.LastName,
                Title              = model.Title,
                CustomerType       = (CustomerType)model.CustomerTypeId,
                Notes              = model.Notes,
                PrimaryActivity    = _repository.Activities.FirstOrDefault(p => p.Id == model.PrimaryActivityId),
                PrimaryDestination = _repository.Destinations.FirstOrDefault(p => p.Id == model.PrimaryDestinationId),
                ModifiedDate       = DateTime.Now,
                AddDate            = DateTime.Now
            };

            _repository.Customers.Add(customer);
            _repository.Save();

            return(RedirectToAction("index", "Customer", new { message = "Customer added successfully" }));
        }
コード例 #5
0
        public ViewResult Add()
        {
            AddViewModel model = new AddViewModel();

            model.LoadData(this.CurrentUserId);
            return(View(model));
        }
コード例 #6
0
        /// <summary>
        /// Method For the Event
        /// </summary>
        /// <param name="e"></param>
        public void OnChanged(ChangeHandlerEventArgs e)
        {
            AddViewModel av = new AddViewModel();

            Changed = new Action <ObservableCollection <Member> >(av.Event_OnChanged);
            Changed.Invoke(e.MemberList);
        }
コード例 #7
0
        public ActionResult Add(Guid id)
        {
            AddViewModel addvm = new AddViewModel();

            addvm.Id = id.ToString();
            return(View(addvm));
        }
コード例 #8
0
        public ActionResult Edit(int id)
        {
            Models.Personnel.AddViewModel model = new AddViewModel();

            //select list
            model.HospitalSelectList = GetHospitalSelectList();

            try
            {
                var result = _personnelService.GetById(id);
                if (result == null)
                {
                    return(View("_ErrorNotExist"));
                }
                model.Id         = result.Id;
                model.TC         = result.TC;
                model.Name       = result.Name;
                model.LastName   = result.LastName;
                model.Phone      = result.Phone;
                model.Address    = result.Address;
                model.UserName   = result.UserName;
                model.Password   = result.Password;
                model.HospitalId = result.HospitalId;
            }
            catch
            {
                ViewBag.ErrorMessage = "Record Not Found";
                return(View("_ErrorNotExist"));
            }

            return(View(model));
        }
コード例 #9
0
        public IActionResult Add(AddViewModel model)
        {
            Image newImage = new Image
            {
                Id       = Guid.NewGuid(),
                FileName = model.Image.FileName,
                Title    = model.Image.Name
            };

            if (model.Image.Length > 0)
            {
                using (var ms = new MemoryStream())
                {
                    model.Image.CopyTo(ms);
                    var fileBytes = ms.ToArray();
                    newImage.ImageFile = fileBytes;
                }
            }

            model.NewEvent.Id       = Guid.NewGuid();
            model.NewEvent.StatusId = Guid.Parse("7ca65c86-0e39-465f-874d-fcb3c9183f1b"); // privremeno rjesenje, stavlja status na upcoming
            newImage.EventId        = model.NewEvent.Id;
            _eventRepository.AddEvent(model.NewEvent);
            _imageRepository.AddImage(newImage);
            return(RedirectToAction("Index"));
        }
コード例 #10
0
        public ActionResult Edit(int id)
        {
            Models.Employee.AddViewModel model = new AddViewModel();
            var apiResponseModel = _employeeService.GetById(SessionHelper.CurrentUser.UserToken, SessionHelper.CurrentLanguageTwoChar, id);

            if (apiResponseModel.ResultStatusCode != ResultStatusCodeStatic.Success)
            {
                ViewBag.ErrorMessage     = apiResponseModel.ResultStatusMessage;
                ViewBag.ErrorMessageList = apiResponseModel.ErrorMessageList;
                return(View(model));
            }

            var employee = apiResponseModel.Data;

            if (employee == null)
            {
                return(View("_ErrorNotExist"));
            }

            model.Id       = employee.Id;
            model.TC       = employee.TC;
            model.Name     = employee.Name;
            model.LastName = employee.LastName;
            model.Phone    = employee.Phone;
            model.Address  = employee.Address;
            model.UserName = employee.UserName;
            model.Password = employee.Password;
            return(View(model));
        }
コード例 #11
0
        public ActionResult Add()
        {
            var allRegions = _regionRepository.GetAll().Select(a => new SelectListItem
            {
                Text  = a.Name,
                Value = a.Id.ToString()
            }).ToList();

            var allWorkModes = _workModeRepository.GetAll().Select(a => new SelectListItem
            {
                Text  = a.Name,
                Value = a.Id.ToString()
            }).ToList();
            var allClinics = _clinicRepository.GetAll()
                             .Select(a => new SelectListItem
            {
                Text = a.Name, Value = a.Id.ToString()
            }
                                     ).ToList();
            var model = new AddViewModel {
                Clinics = allClinics, Regions = allRegions, WorkdModes = allWorkModes
            };

            if (User.IsInRole(Models.User.DOCTOR_ROLE))
            {
                var doctorId = User.FindFirstValue(ClaimTypes.NameIdentifier);

                var clinicId = _clinicRepository.GetDoctorsClinics(doctorId).FirstOrDefault().Id;

                model.ClinicId = clinicId;
            }
            return(View("Add", model));
        }
コード例 #12
0
        public async Task <ActionResult <PersonViewModel> > AddPerson(AddViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }


            if (await _personRepository.CheckEmail(model.Email))
            {
                return(BadRequest("El email ya existe"));
            }



            var person = _mapper.Map <Person>(model);



            var newPerson = await _personRepository.Add(person);

            if (newPerson == null)
            {
                return(BadRequest());
            }

            var newPersonResult = _mapper.Map <PersonViewModel>(newPerson);

            return(CreatedAtAction(nameof(AddPerson), new { id = newPersonResult.IdPerson }, newPersonResult));
        }
コード例 #13
0
 public ActionResult Add()
 {
     Models.Employee.AddViewModel model = new AddViewModel();
     //select list
     model.SexSelectList = GetSexSelectList(SessionHelper.CurrentUser.UserToken, SessionHelper.CurrentLanguageTwoChar);
     return(View(model));
 }
コード例 #14
0
        public Response Add(AddViewModel model)
        {
            if (!User.IsAuthenticated)
            {
                return(Redirect("/Home"));
            }

            var(isValid, errors) = tripService.IsValid(model);

            if (!isValid)
            {
                return(View(errors, "/Error"));
            }

            try
            {
                tripService.AddTrip(model);
            }
            catch (Exception)
            {
                return(View(new List <ErrorViewModel>()
                {
                    new ErrorViewModel("Unexpected error!")
                }));
            }

            return(Redirect("/Trips/All"));
        }
コード例 #15
0
        public ActionResult Edit(int id)
        {
            Models.Auth.AddViewModel model = new AddViewModel();
            var apiResponseModel           = _authService.GetById(SessionHelper.CurrentUser.UserToken, SessionHelper.CurrentLanguageTwoChar, id);

            if (apiResponseModel.ResultStatusCode != ResultStatusCodeStatic.Success)
            {
                ViewBag.ErrorMessage     = apiResponseModel.ResultStatusMessage;
                ViewBag.ErrorMessageList = apiResponseModel.ErrorMessageList;
                return(View(model));
            }

            var auth = apiResponseModel.Data;

            if (auth == null)
            {
                return(View("_ErrorNotExist"));
            }

            model.Id     = auth.Id;
            model.Code   = auth.Code;
            model.NameTR = auth.NameTR;
            model.NameEN = auth.NameEN;
            return(View(model));
        }
コード例 #16
0
        public JsonResult Add(AddViewModel model)
        {
            SysSalesmanUser user = new SysSalesmanUser();

            user.UserName           = string.Format("YW{0}", model.SysSalesmanUser.UserName);
            user.FullName           = model.SysSalesmanUser.FullName;
            user.PasswordHash       = "888888";
            user.Email              = model.SysSalesmanUser.Email;
            user.PhoneNumber        = model.SysSalesmanUser.PhoneNumber;
            user.IsModifyDefaultPwd = false;
            user.IsDelete           = false;
            user.Status             = Enumeration.UserStatus.Normal;
            user.Creator            = this.CurrentUserId;
            user.CreateTime         = DateTime.Now;

            var identiy = new AspNetIdentiyAuthorizeRelay <SysSalesmanUser>();


            if (identiy.UserExists(user.UserName.Trim()))
            {
                return(Json(ResultType.Failure, WebBackOperateTipUtils.USER_EXISTS));
            }


            bool r = identiy.CreateUser(this.CurrentUserId, user, null);

            if (!r)
            {
                return(Json(ResultType.Failure, WebBackOperateTipUtils.ADD_FAILURE));
            }



            return(Json(ResultType.Success, WebBackOperateTipUtils.ADD_SUCCESS));
        }
コード例 #17
0
        public AddWindow()
        {
            InitializeComponent();

            model       = new AddViewModel();
            DataContext = model;
        }
コード例 #18
0
        public async Task <IActionResult> Index()
        {
            // User = lightweight object containing user info
            var currentUser = await UserManager.GetUserAsync(User);

            // Should never be null due to authorize attribute
            if (currentUser == null)
            {
                return(Challenge());
            }

            // Retrieve Groceries Async
            var groceries = await GroceryService.GetAllGroceriesToBeFetchedAsync(currentUser);

            if (groceries == null)
            {
                return(BadRequest("Could not retrieve Groceries"));
            }

            var viewModel = new AddViewModel {
                Groceries = groceries
            };

            return(View(viewModel));
        }
コード例 #19
0
        public JsonResult Add(AddViewModel model)
        {
            var identity = new AspNetIdentiyAuthorizeRelay <SysUser>();

            identity.CreateMenu(this.CurrentUserId, model.SysMenu, model.SysMenu.Permission);
            return(Json(ResultType.Success, WebBackOperateTipUtils.ADD_SUCCESS));
        }
コード例 #20
0
        public ActionResult Add(AddViewModel addviewmodel)
        {
            Gallon gallon = new Gallon
            {
                AutoID        = addviewmodel.AutoID,
                TotalMiles    = (int)(addviewmodel.TotalMiles ?? 0),
                TotalGallons  = addviewmodel.TotalGallons ?? 0,
                DrivenMiles   = addviewmodel.DrivenMiles ?? 0,
                TotalPrice    = addviewmodel.TotalPrice,
                TankFilled    = addviewmodel.TankFilled,
                StationID     = addviewmodel.SelectedStation,
                Latitude      = addviewmodel.Latitude,
                Longitude     = addviewmodel.Longitude,
                EngineRunTime = addviewmodel.EngineRunTime != null?TimeSpan.Parse(addviewmodel.EngineRunTime.Replace(".", ":")) : new TimeSpan(),
                                    GasolineTypeID = addviewmodel.SelectedGasType
            };

            if (addviewmodel.GasDate != null)
            {
                DateTime dt;
                DateTime.TryParse(addviewmodel.GasDate, out dt);
                gallon.GasDate = dt;
            }
            else
            {
                gallon.GasDate = DateTime.Now;
            }


            ae.Gallons.Add(gallon);
            int NumberOfChanges = ae.SaveChanges();

            return(RedirectToAction("JSONList", new { id = addviewmodel.AutoID, viewall = false }));
        }
コード例 #21
0
        public ViewResult Add()
        {
            AddViewModel model = new AddViewModel();

            model.GetModel();
            return(View(model));
        }
コード例 #22
0
        public ActionResult Edit(int id)
        {
            Models.Announcement.AddViewModel model = new AddViewModel();

            var apiBroadcastResponseModel = _broadcastService.GetById(SessionHelper.CurrentUser.UserToken, SessionHelper.CurrentLanguageTwoChar, id);

            if (apiBroadcastResponseModel.ResultStatusCode != ResultStatusCodeStatic.Success)
            {
                return(RedirectToAction(nameof(AnnouncementController.List), "Announcement", new { errorMessage = apiBroadcastResponseModel.ResultStatusMessage }));
            }
            if (apiBroadcastResponseModel == null || apiBroadcastResponseModel.Data == null || apiBroadcastResponseModel.ResultStatusCode != ResultStatusCodeStatic.Success)
            {
                return(View("_ErrorNotExist"));
            }

            model.SessionGuid     = Guid.NewGuid().ToString();
            model.DisplayLanguage = SessionHelper.CurrentLanguageTwoChar;
            model.Id = apiBroadcastResponseModel.Data.Id;
            model.BroadcastTypeId       = apiBroadcastResponseModel.Data.BroadcastTypeId;
            model.SessionImageFileName  = String.IsNullOrEmpty(apiBroadcastResponseModel.Data.ImageFilePath) ? "" : ConfigHelper.ApiBaseUrl + apiBroadcastResponseModel.Data.ImageFilePath;
            model.ValidationEndDateTime = apiBroadcastResponseModel.Data.ValidationEndDateTime;
            model.IsActive      = apiBroadcastResponseModel.Data.IsActive;
            model.TitleTR       = apiBroadcastResponseModel.Data.TitleTR;
            model.TitleEN       = apiBroadcastResponseModel.Data.TitleEN;
            model.DescriptionTR = apiBroadcastResponseModel.Data.DescriptionTR;
            model.DescriptionEN = apiBroadcastResponseModel.Data.DescriptionEN;
            model.VideoFileUrl  = apiBroadcastResponseModel.Data.VideoFileUrl;

            //select list
            model.BroadcastTypeSelectList = GetBroadcastTypeSelectList(SessionHelper.CurrentUser.UserToken, SessionHelper.CurrentLanguageTwoChar);
            return(View(model));
        }
コード例 #23
0
        public ActionResult Add(int locationId)
        {
            if (locationId <= 0)
            {
                return(View("_ErrorNotExist"));
            }
            Models.LocationMove.AddViewModel model = new AddViewModel();
            var apiResponseModel = _locationMoveService.GetLocationByLocationIdWithDetail(locationId).Result;

            if (apiResponseModel.Status == ResultStatusCodeStatic.Success)
            {
                //not error
            }
            else
            {
                ViewBag.ErrorMessage = apiResponseModel.Message;
                return(View(model));
            }

            var roomWithDetail = apiResponseModel.Data;

            if (roomWithDetail.IsEmpty == false)
            {
                return(View("_ErrorNotExist"));
            }
            model.LocationId = roomWithDetail.LocationId;

            //select list
            model.CarSelectList = GetCarSelectList();
            return(View(model));
        }
コード例 #24
0
 public IActionResult Add(AddViewModel model)
 {
     if (ModelState.IsValid)
     {
         if (model.Text == null)
         {
             model.Text = "";
         }
         if (model.Labels == null)
         {
             model.Labels = "";
         }
         if ((!model.Time.HasValue) || ((DateTime.UtcNow - model.Time.Value).TotalSeconds > 0))
         {
             model.Time = null;
         }
         Guid     userId = new Guid(_userManager.GetUserId(User));
         TodoItem item   = new TodoItem(model.Text, userId);
         item.DateDue = model.Time;
         foreach (string label in model.Labels.Trim().Split(','))
         {
             if (label != "")
             {
                 item.Labels.Add(_repository.GenerateLabel(label));
             }
         }
         _repository.Add(item);
         return(RedirectToAction("Index"));
     }
     return(View(model));
 }
コード例 #25
0
        public ActionResult Edit(int id)
        {
            Models.Hospital.AddViewModel model = new AddViewModel();

            //select list
            model.CitySelectList = GetCitySelectList();

            try
            {
                var result = _hospitalService.GetById(id);
                if (result == null)
                {
                    return(View("_ErrorNotExist"));
                }
                model.Id       = result.Id;
                model.Name     = result.Name;
                model.Phone    = result.Phone;
                model.Address  = result.Address;
                model.CityCode = result.CityCode;
            }
            catch
            {
                ViewBag.ErrorMessage = "Record Not Found";
                return(View("_ErrorNotExist"));
            }

            return(View(model));
        }
コード例 #26
0
        public ActionResult Edit(int locationId)
        {
            if (locationId <= 0)
            {
                return(View("_ErrorNotExist"));
            }
            Models.LocationMove.AddViewModel model = new AddViewModel();
            var locationWithDetail = _locationMoveService.GetLocationByLocationIdWithDetail(locationId).Result.Data;

            if (locationWithDetail.IsEmpty == true)
            {
                return(View("_ErrorNotExist"));
            }

            var locationMoveResponce = _locationMoveService.GetById(locationWithDetail.LocationMove_ID).Result.Data;

            if (locationMoveResponce == null)
            {
                return(View("_ErrorNotExist"));
            }
            model.CarId         = locationMoveResponce.CarId;
            model.LocationId    = locationMoveResponce.LocationId;
            model.EntryDate     = locationMoveResponce.EntryDate;
            model.ExitDate      = locationMoveResponce.ExitDate;
            model.Id            = locationMoveResponce.Id;
            model.Location_Name = locationWithDetail.LocationName;

            model.CarSelectList = GetCarSelectList();
            return(View(model));
        }
コード例 #27
0
 public ActionResult Add()
 {
     Models.Hospital.AddViewModel model = new AddViewModel();
     //select list
     model.CitySelectList = GetCitySelectList();
     return(View(model));
 }
コード例 #28
0
        public ActionResult Delete(int id)
        {
            Models.Movies.AddViewModel model = new AddViewModel();
            //select lists
            var apiResponseModel = _moviesService.GetById(SessionHelper.CurrentUser.UserToken, id);

            if (apiResponseModel.ResultStatusCode != ResultStatusCodeStatic.Success)
            {
                ViewBag.ErrorMessage = apiResponseModel.ResultStatusMessage;
                return(RedirectToAction(nameof(MoviesController.List)));
            }
            var movies = apiResponseModel.Data;

            if (movies == null)
            {
                ViewBag.ErrorMessage = "Not Found Record";
                return(RedirectToAction(nameof(MoviesController.List)));
            }
            var apiDeleteResponseModel = _moviesService.Delete(SessionHelper.CurrentUser.UserToken, id);

            if (apiDeleteResponseModel.ResultStatusCode != ResultStatusCodeStatic.Success)
            {
                ViewBag.ErrorMessage = apiDeleteResponseModel.ResultStatusMessage;
                return(RedirectToAction(nameof(MoviesController.List)));
            }

            return(RedirectToAction(nameof(MoviesController.List)));
        }
コード例 #29
0
        public async Task <IActionResult> Add(AddViewModel addViewModel)
        {
            if (ModelState.IsValid)
            {
                ApplicationUser user = await _userManager.GetUserAsync(HttpContext.User);

                String[]      array   = addViewModel.BarTagString.Split(';');
                List <BarTag> BarTags = new List <BarTag>();
                Bar           bar     = new Bar(addViewModel.Name
                                                , BarTags
                                                , addViewModel.OpeningTime
                                                , addViewModel.ClosingTime
                                                , addViewModel.Picture
                                                , Guid.Parse(user.Id))
                {
                    BarTags = BarTags
                };
                //for (int i = 0; i < array.Length; i++)
                //{
                //    _repository.AddTag(array[i].Trim(),bar);
                //}
                _repository.Add(bar);
                return(RedirectToAction("Index"));
            }
            return(View(addViewModel));
        }
コード例 #30
0
        public ActionResult Edit(int id)
        {
            Models.User.AddViewModel model = new AddViewModel();
            //select lists
            model.ProfileSelectList = GetProfileSelectList("");
            var apiResponseModel = _userService.GetById(SessionHelper.CurrentUser.UserToken, id);

            if (apiResponseModel.ResultStatusCode != ResultStatusCodeStatic.Success)
            {
                model.ProfileSelectList = GetProfileSelectList("");
                ViewBag.ErrorMessage    = apiResponseModel.ResultStatusMessage;
                return(View(model));
            }
            var user = apiResponseModel.Data;

            if (user == null)
            {
                return(View("_ErrorNotExist"));
            }
            model.Id        = user.Id;
            model.UserName  = user.UserName;
            model.Password  = user.Password;
            model.Name      = user.Name;
            model.Surname   = user.Surname;
            model.Mail      = user.Mail;
            model.ProfileId = user.ProfileId;
            return(View(model));
        }
コード例 #31
0
        public ActionResult Add(Guid id)
        {
            var obj = AppLookups.GetCacheIndexEntry(id);
            if (obj == null) { PlaceNotFound(); }

            var model = new AddViewModel() { ObjectId = id, ObjectSlug = obj.SlugUrl, ObjectName = obj.Name, Title = "Climbing media of " + obj.Name, ChooseFromExisting = true };

            ViewBag.MyMedia = mediaSvc.GetMediaByUserWithObjectRefereces(CfIdentity.UserID).ToList();

            return View(model);
        }
コード例 #32
0
        public ActionResult Add(Guid id, AddViewModel model)
        {
            if (ModelState.IsValid)
            {
                SaveMediaWithTag(model);

                return Redirect("/" + CfUrlProvider.MediaUrlPrefix + model.ObjectSlug);
            }
            else
            {
                return View(model);
            }
        }
コード例 #33
0
        public Media SaveMediaWithTag(AddViewModel model)
        {
            var id = model.ObjectId;
            var type = model.Type;
            var media = new Media() { FeedVisible = true };
            media.InjectFrom(model);

            if (type == MediaType.Image)
            {
                CropAndSaveImageFromUrlAndDeleteOriginalAtUrl(model.Content,
                    stream => mediaSvc.CreateImageMedia(media, id, stream).Content);
            }
            else if (type == MediaType.Youtube)
            {
                YouTubeApiResult data = new JavaScriptSerializer().Deserialize<YouTubeApiResult>(model.Content);
                if (data.Description.Length > 1499) { data.Description = data.Description.Substring(0, 1499); }
                mediaSvc.CreateYouTubeMedia(media, id, data);
            }
            else if (type == MediaType.Vimeo)
            {
                VimeoApiResult data = new JavaScriptSerializer().Deserialize<VimeoApiResult>(model.Content);
                if (data.Description.Length > 1499) { data.Description = data.Description.Substring(0, 1499); }
                mediaSvc.CreateVimeoMedia(media, id, data);
            }
            else
            {
                throw new NotImplementedException("JSK Cmon you have implemented adding media type : " + type.ToString());
            }

            return media;
        }
コード例 #34
0
 public ActionResult Index(AddViewModel vm)
 {
     vm.Add();
     return View(vm);
 }