public async Task <ActionResult> CreateLocation(CreateLocationViewModel model) { var locationRepository = new LocationRepo(); var orderRepository = new OrderRepo(); var customerRepository = new CustomerRepo(); var userId = User.Identity.GetUserId(); var location = new Models.Location { Title = model.Title, SecondTitle = model.SecondTitle, Customer = model.Customer, }; var order = new Order { LocationId = location.LocationId, UserId = userId }; location.UsersId.Add(userId); var testCustIds = await customerRepository.GetAllAsync(); await locationRepository.AddAsync(location); await orderRepository.AddAsync(order); return(RedirectToAction("Index", "Home", new { area = "" })); }
public async Task <IActionResult> Create(CreateLocationViewModel model) { if (ModelState.IsValid) { Location newLocation = new Location() { LocationId = Guid.NewGuid().ToString(), LocationName = model.LocationName }; if (await _locationServices.CreateLocation(newLocation)) { var userMessage = new MessageVM() { CssClassName = "alert alert-success", Title = "Thành công", Message = "Tạo địa điểm mới thành công" }; TempData["UserMessage"] = JsonConvert.SerializeObject(userMessage); } else { var userMessage = new MessageVM() { CssClassName = "alert alert-danger", Title = "Không thành công", Message = "Đã có lỗi khi thao tác, xin mời thử lại" }; TempData["UserMessage"] = JsonConvert.SerializeObject(userMessage); }; } return(RedirectToAction(actionName: "Index", controllerName: "Location")); }
public async Task <InvokeResult> AddLocationAsync(CreateLocationViewModel newLocation, EntityHeader org, EntityHeader user) { var location = new OrgLocation(); newLocation.MapToOrganizationLocation(location); location.IsPublic = false; location.Organization = org; location.OwnerOrganization = org; if (EntityHeader.IsNullOrEmpty(location.AdminContact)) { location.AdminContact = user; } if (EntityHeader.IsNullOrEmpty(location.TechnicalContact)) { location.TechnicalContact = user; } SetCreatedBy(location, user); ValidationCheck(location, Core.Validation.Actions.Create); await AuthorizeAsync(location, AuthorizeResult.AuthorizeActions.Create, user, org); await _locationRepo.AddLocationAsync(location); return(InvokeResult.Success); }
public ResponseViewModel CreateLocation(CreateLocationViewModel model) { ResponseViewModel reponse = new ResponseViewModel(); try { Localizacion localization = new Localizacion { IdEvento = model.IdEvento, Activo = "1", Comentario = model.Comentario, Direccion = model.Direccion, Latitud = model.Latitud, Longitud = model.Longitud }; _eventPlusContext.Localizacion.Add(localization); _eventPlusContext.SaveChanges(); reponse.Type = "success"; reponse.Response = "El regitsro se creo exitosamente."; return(reponse); } catch (Exception ex) { reponse.Type = "error"; reponse.Response = "Error en el procedimiento. ---> " + ex.Message; return(reponse); } }
public async Task AddLocationAsync(CreateLocationViewModel newLocation, EntityHeader addedByUser) { ValidationCheck(newLocation, Core.Validation.Actions.Create); var location = new OrganizationLocation(); location.SetId(); var currentUser = await _appUserRepo.FindByIdAsync(addedByUser.Id); var organization = await _organizationRepo.GetOrganizationAsync(newLocation.OrganizationId); location.Organization = organization.ToEntityHeader(); if (EntityHeader.IsNullOrEmpty(location.AdminContact)) { location.AdminContact = addedByUser; } if (EntityHeader.IsNullOrEmpty(location.TechnicalContact)) { location.TechnicalContact = addedByUser; } SetCreatedBy(location, addedByUser); await _locationRepo.AddLocationAsync(location); }
public ActionResult AreaCreate() { //authorize admin if (acl.AuthorizeAdmin(User.Identity.GetUserId()) == false) { return(HttpNotFound()); } CreateLocationViewModel temp = new CreateLocationViewModel(); return(View(temp)); }
// GET: Location/Create public ActionResult Create(string businessId) { var userBusinesses = _user.Repository.GetCurrent.MyBusinesses; if (userBusinesses.IsNullOrEmpty()) { return(Content("If you want to create a location, you have to create a business first.")); } var model = new CreateLocationViewModel(userBusinesses, businessId); return(View(model)); }
public async Task <ActionResult> CreateLocation() { var model = new CreateLocationViewModel(); var customerRepository = new CustomerRepo(); var customers = new List <string>(); foreach (var v in await customerRepository.GetAllAsync()) { customers.Add(v.Name); } SelectList selectListCustomers = new SelectList(customers); ViewBag.Customers = selectListCustomers; return(View()); }
public IHttpActionResult Post(CreateLocationViewModel createModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var locationData = new Location(); AutoMapper.Mapper.Map(createModel, locationData); _locationService.AddLocation(locationData); var locationViewModel = new LocationViewModel(); AutoMapper.Mapper.Map(locationData, locationViewModel); return(Created(new Uri(Request.RequestUri + "api/loctions" + locationViewModel.Id), locationViewModel)); }
public ActionResult AreaCreate(CreateLocationViewModel cur) { if (ModelState.IsValid) { Area create = new Area { Name = cur.Name, Slug = cur.Slug, Hidden = false }; if (locl.AdminAreaCreate(create)) { return(RedirectToAction("AdminArea")); } TempData["CreateError"] = "Name or Slug already exists. Invalid Creation."; return(View(cur)); } return(View(cur)); }
public async Task <IActionResult> CreateLocationAsync(CreateLocationViewModel model) { try { LocationDto location = new LocationDto { Title = model.Title }; await locationService.CreateAsync(location); return(RedirectToAction("LocationsList", "Location")); } catch (Exception ex) { ErrorViewModel errorModel = new ErrorViewModel(); errorModel.ErrorMessage = ex.Message.ToString(); return(View("Views/Shared/Error.cshtml", errorModel)); } }
public PartialViewResult Create(CreateLocationViewModel model) { try { if (ModelState.IsValid == false) { _response.HasFailed("Please check if you entered valid information."); return(PartialView("Create/_CreateResponsePartial", _response as LocationResponse)); } model.LocationId = ObjectId.GenerateNewId(); _atomicWork.Add(model); _response.HasSucceeded("Location was created successfully."); return(PartialView("Create/_CreateResponsePartial", _response as LocationResponse)); } catch { _response.HasFailed("We apologize, location could not be created."); return(PartialView("Create/_CreateResponsePartial", _response as LocationResponse)); } }
public async Task <IActionResult> Create(CreateLocationViewModel input) { try { string url = await _blobManager.UploadImageAsBlob(input.Photo); CreateLocationDTO data = new CreateLocationDTO() { Name = input.Name, PhotoURL = url, ProjectId = input.ProjectId, Latitude = input.Latitude, Longitude = input.Longitude, UserId = input.UserId }; await _locationService.CreateLocation(data); return(Ok()); } catch (Exception) { return(BadRequest()); } }
public void Add(CreateLocationViewModel viewModel) { try { var location = new Models.Location.Location { Id = viewModel.LocationId, BusinessId = viewModel.BusinessId, Address = viewModel.Address, City = viewModel.City, Zip = viewModel.Zip, Country = viewModel.Country //TODO: ADD LOCATION NAME }; var headquaters = new BusinessHeadquaters { Id = viewModel.LocationId, City = viewModel.City }; Lock(); _locationRepository.Add(location); _businessRepository.AddHeadquaters(headquaters, location.BusinessId); } catch (Exception) { //TODO: Rollback logic throw new Exception("Failed to perform atomic action - " + Desc); } finally { Unlock(); } }
public CreateLocationViewModel GetCreateLocationViewModel(EntityHeader org, EntityHeader user) { return(CreateLocationViewModel.CreateNew(org, user)); }
public IActionResult CreateLocation([FromBody] CreateLocationViewModel model) { var user = _eventoService.CreateLocation(model); return(Ok(user)); }
public async Task <string> PostLocation([FromBody] CreateLocationViewModel jsondata) { return("https://www.openstreetmap.org/#map=9/" + jsondata.PositionX + "/" + jsondata.PositionY); //"https://www.openstreetmap.org/#map=9/50.6015/17.6825 }