public async Task <Result <UserLocationModel> > Handle(AddLocation request, CancellationToken cancellationToken)
        {
            var isValid = await _validator.IsValidAsync(request);

            if (!isValid)
            {
                return(Result.Failure <UserLocationModel>("Validation failed"));
            }

            var user = await _context.Users.FirstAsync(u => u.Sub == request.UserSub, cancellationToken);

            var location = new UserLocation
            {
                Latitude  = request.Location.Latitude,
                Longitude = request.Location.Longitude,
                Address   = request.Location.Address,
                Type      = request.Location.Type,
                User      = user
            };

            await _context.UserLocations.AddAsync(location, cancellationToken);

            await _context.SaveChangesAsync(cancellationToken);

            return(new UserLocationModel
            {
                Id = location.Id,
                Latitude = location.Latitude,
                Longitude = location.Longitude,
                Address = location.Address,
                Type = location.Type
            });
        }
Exemple #2
0
        void OnGUI()
        {
            Information();

            GUIPartition();

            using (new EditorGUILayout.VerticalScope())
            {
                EditorGUILayout.LabelField("付け足したい名前を記入");

                EditorGUI.BeginChangeCheck();
                addNameProp.stringValue = GUILayout.TextField(addNameProp.stringValue);
                if (EditorGUI.EndChangeCheck())
                {
                    // スペースがあったら強制的に消す
                    addNameProp.stringValue = Regex.Replace(addNameProp.stringValue, @"\s", "");
                }

                GUIPartition();

                // 頭につけるのか最後につけるのか選択する (Head = 0 , Tail = 1)
                EditorGUILayout.LabelField("頭につけるのか尾につけるのか選択");
                selectedProp.intValue = GUILayout.Toolbar(selectedProp.intValue, new string[] { "Head", "Tail" });
                selectedAddLocation   = (AddLocation)selectedProp.intValue;

                GUIPartition();

                // 対象オブジェクト取得
                EditorGUILayout.LabelField("対象オブジェクト");
                if (GUILayout.Button("対象オブジェクト取得"))
                {
                    GetObject();
                }

                GUIPartition();

                scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);
                {
                    // 取得オブジェクト表示
                    ShowSelectObjects();
                }
                EditorGUILayout.EndScrollView();

                GUIPartition();

                // 名前を付け足す
                EditorGUILayout.LabelField("名前を付け足す");
                if (GUILayout.Button("付け足す"))
                {
                    AddName();
                }

                GUIPartition();

                // 結果を表示
                ShowResultMessage();
            }

            so.ApplyModifiedProperties();
        }
Exemple #3
0
 public async Task <IActionResult> AddGroupAsync([FromBody] AddLocation addGroupAc)
 {
     if (string.IsNullOrEmpty(addGroupAc.Name.Trim()))
     {
         return(Ok(new SharedLookUpResponse()
         {
             HasError = true,
             ErrorType = SharedLookUpResponseType.Name,
             Message = "Location name can't be null or empty"
         }));
     }
     else if (string.IsNullOrEmpty(addGroupAc.Code.Trim()))
     {
         return(Ok(new SharedLookUpResponse()
         {
             HasError = true,
             ErrorType = SharedLookUpResponseType.Name,
             Message = "Location code can't be null or empty"
         }));
     }
     else
     {
         return(Ok(await locationManagementRepository.AddComponentAsync(addGroupAc, await GetUserCurrentSelectedInstituteIdAsync())));
     }
 }
 public async Task<SharedLookUpResponse> AddComponentAsync(AddLocation addComponent, int instituteId)
 {
     if (!await iMSDbContext.Locations.AnyAsync(x => x.InstituteId == instituteId && x.Code.ToLowerInvariant() == addComponent.Code.ToLowerInvariant()))
     {
         var componentGroup = new Location()
         {
             IsParent = addComponent.IsParent,
             Alias = addComponent.Alias,
             InstituteId = instituteId,
             Name = addComponent.Name,
             Code = addComponent.Code,
             Description = addComponent.Description,
             Status = addComponent.Status
         };
         if(addComponent.BillingAddressId != null)
         {
             componentGroup.BillingAddressId = addComponent.BillingAddressId;
         }
         if(addComponent.ShippingAddressId != null)
         {
             componentGroup.ShippingAddressId = addComponent.ShippingAddressId;
         }
         iMSDbContext.Locations.Add(componentGroup);
         await iMSDbContext.SaveChangesAsync();
         return new SharedLookUpResponse() { HasError = false, Message = "Location added successfully" };
     }
     else
     {
         return new SharedLookUpResponse() { HasError = true, ErrorType = SharedLookUpResponseType.Code, Message = "Location with same code is already existed" };
     }
 }
 public async Task AddLocation(AddLocation model)
 {
     var location = new Data_Access_Layer.Location()
     {
         Name = model.Name
     };
     await LocationRepository.Add(location);
 }
Exemple #6
0
        private void AddLocation_Click(object sender, RoutedEventArgs e)
        {
            //Opening requred form
            AddLocation ViewNextForm = new AddLocation();

            Frame.Content = ViewNextForm;
            Frame.NavigationService.RemoveBackEntry();
        }
        private void btnLocation_Click(object sender, EventArgs e)
        {
            AddLocation loc = new AddLocation();

            addControl(loc);

            //indicator.Visible = true;

            //indicator.Location = new Point(btnLocation.Location.X + 200, btnLocation.Location.Y - 33);
            btnLocation.SendToBack();

            //indicator.Top = btnLocation.Top;
        }
        public async Task <HttpResult <bool> > AddLocation(Location location, CancellationToken token = default(CancellationToken))
        {
            var result = new HttpResult <bool>();

            var model = new AddLocation
            {
                Name = location.Name
            };

            await _unitOfWork.AddLocation(model);

            return(result);
        }
Exemple #9
0
        public int AddLocation(AddLocation addLocation)
        {
            using (var context = new INVENTORYEntities())
            {
                LocationZone locationZone = new LocationZone();


                locationZone.locationZone1 = addLocation.LocationName;


                context.LocationZone.Add(locationZone);
                context.SaveChanges();
                return(locationZone.id);
            }
        }
        public ValueDataResponse <Location> Update(AddLocation location)
        {
            Location LocationInfo = _mapper.Map <Location>(location);

            return(_unitOfWork.Locations.UpdateLocation(LocationInfo));
        }
 public IActionResult Post([FromBody] LocationDto dto, [FromServices] AddLocation command)
 {
     _executor.ExecuteCommand(command, dto);
     return(StatusCode(StatusCodes.Status201Created));
 }
        public async Task <IActionResult> AddLocation([FromBody] AddLocation model)
        {
            await _unitOfWork.AddLocation(model);

            return(Ok());
        }