Beispiel #1
0
        public OperationResult AddUserVehicle(Vehicle vehicle)
        {
            try
            {
                vehicle.UserId = applicationSessionService.GetUserFromApplicationSession().UserId;
                HttpResponseMessage tokenResponse = httpClientService.Post("api/Vehicle", vehicle);

                if (tokenResponse.IsSuccessStatusCode)
                {
                    return(new OperationResult {
                        ResultCode = ResultCode.Successful
                    });
                }

                OperationResult operationResult = JsonConvert.DeserializeObject <OperationResult>(tokenResponse.Content.ReadAsStringAsync().Result);
                operationResult.ResultCode = ResultCode.Error;
                return(operationResult);
            }
            catch (Exception)
            {
                return(new OperationResult {
                    ResultCode = ResultCode.Error, Message = "Wystąpił problem z rejestracją"
                });
            }
        }
        private void BtnSentMessage_Click(object sender, EventArgs e)
        {
            BLL.Models.Message message = new BLL.Models.Message
            {
                Title          = string.Empty,
                Content        = FindViewById <EditText>(Resource.Id.etMessageCreateor).Text,
                SentDate       = DateTime.Now,
                OrderId        = int.Parse(Intent.GetStringExtra("OrderId")),
                UserReceiverId = int.Parse(Intent.GetStringExtra("UserReceiverId")),
                UserSenderId   = applicationSessionService.GetUserFromApplicationSession().UserId
            };

            OperationResult operationResult = messageService.SendMessage(message);

            if (operationResult.ResultCode != ResultCode.Successful)
            {
                Toast.MakeText(Application.Context, operationResult.Message, ToastLength.Long).Show();
            }
            else
            {
                FindViewById <EditText>(Resource.Id.etMessageCreateor).Text = string.Empty;
            }

            RefreshGvMessageList(FindViewById <GridView>(Resource.Id.gvMessageList));
        }
Beispiel #3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_menu);
            FindViewById <Button>(Resource.Id.btnMyVehicle).Click += BtnMyVehicle_Click;
            FindViewById <Button>(Resource.Id.btnMyAccount).Click += BtnMyAccount_Click;
            FindViewById <Button>(Resource.Id.btnContact).Click   += BtnContact_Click;
            FindViewById <Button>(Resource.Id.btnLogout).Click    += BtnLogout_Click;
            User user = applicationSessionService.GetUserFromApplicationSession();

            if (user.PermissionId == (int)PermissionId.User)
            {
                FindViewById <Button>(Resource.Id.btnDayTimetable).Visibility          = ViewStates.Gone;
                FindViewById <Button>(Resource.Id.btnTimetableManagement).Visibility   = ViewStates.Gone;
                FindViewById <Button>(Resource.Id.btnServiceManagement).Visibility     = ViewStates.Gone;
                FindViewById <Button>(Resource.Id.btnVehiclePartManagement).Visibility = ViewStates.Gone;
                FindViewById <Button>(Resource.Id.btnWorkersManagement).Visibility     = ViewStates.Gone;
            }
            else if (user.PermissionId == (int)PermissionId.Admin)
            {
                FindViewById <Button>(Resource.Id.btnDayTimetable).Click              += BtnDayTimetable_Click;
                FindViewById <Button>(Resource.Id.btnMyVehicle).Visibility             = ViewStates.Gone;
                FindViewById <Button>(Resource.Id.btnContact).Visibility               = ViewStates.Gone;
                FindViewById <Button>(Resource.Id.btnTimetableManagement).Visibility   = ViewStates.Gone;
                FindViewById <Button>(Resource.Id.btnServiceManagement).Visibility     = ViewStates.Gone;
                FindViewById <Button>(Resource.Id.btnVehiclePartManagement).Visibility = ViewStates.Gone;
                FindViewById <Button>(Resource.Id.btnWorkersManagement).Visibility     = ViewStates.Gone;
            }
            else if (user.PermissionId == (int)PermissionId.SuperAdmin)
            {
                FindViewById <Button>(Resource.Id.btnTimetableManagement).Click   += BtnTimetableManagement_Click;
                FindViewById <Button>(Resource.Id.btnServiceManagement).Click     += BtnServiceManagement_Click;
                FindViewById <Button>(Resource.Id.btnVehiclePartManagement).Click += BtnVehiclePartManagement_Click;
                FindViewById <Button>(Resource.Id.btnWorkersManagement).Click     += BtnWorkersManagement_Click;
                FindViewById <Button>(Resource.Id.btnMyVehicle).Text          = "Samochody klientów";
                FindViewById <Button>(Resource.Id.btnContact).Visibility      = ViewStates.Gone;
                FindViewById <Button>(Resource.Id.btnDayTimetable).Visibility = ViewStates.Gone;
            }
        }
Beispiel #4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_register);
            FindViewById <Button>(Resource.Id.btnRegister).Click += BtnRegister_Click;
            if (Intent.GetStringExtra(nameof(OperationType)) == OperationType.Edit.GetDescription())
            {
                User user = JsonConvert.DeserializeObject <User>(Intent.GetStringExtra("SelectedWorker") ?? string.Empty)
                            ?? applicationSessionService.GetUserFromApplicationSession();
                FindViewById <EditText>(Resource.Id.editTextUsername).Enabled  = false;
                FindViewById <EditText>(Resource.Id.editTextFirstName).Enabled = false;
                FindViewById <EditText>(Resource.Id.editTextLastName).Enabled  = false;

                FindViewById <TextView>(Resource.Id.tvUserDetailsTitle).Text      = "Dane o koncie:";
                FindViewById <EditText>(Resource.Id.editTextUsername).Text        = user.Username;
                FindViewById <EditText>(Resource.Id.editTextFirstName).Text       = user.FirstName;
                FindViewById <EditText>(Resource.Id.editTextLastName).Text        = user.LastName;
                FindViewById <EditText>(Resource.Id.editTextEmail).Text           = user.Email;
                FindViewById <EditText>(Resource.Id.editTextPhoneNumber).Text     = user.PhoneNumber.ToString();
                FindViewById <EditText>(Resource.Id.editTextPassword).Text        = user.Password;
                FindViewById <EditText>(Resource.Id.editTextConfirmPassword).Text = user.Password;
                permissionId = user.PermissionId;
                userId       = user.UserId;

                FindViewById <Button>(Resource.Id.btnRegister).Text = "Zapisz zmiany";
            }
            else
            {
                if (applicationSessionService.GetUserFromApplicationSession()?.PermissionId == (int)PermissionId.SuperAdmin)
                {
                    permissionId = (int)PermissionId.Admin;
                }
                else
                {
                    permissionId = (int)PermissionId.User;
                }
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_orderDetails);

            FindViewById <Button>(Resource.Id.btnService).Click              += BtnService_Click;
            FindViewById <Button>(Resource.Id.btnMessages).Click             += BtnMessages_Click;
            FindViewById <Button>(Resource.Id.btnDeleteOrder).Click          += BtnDeleteOrder_Click;
            FindViewById <TextView>(Resource.Id.btnAddDescription).Click     += BtnAddDescription_Click;
            FindViewById <TextView>(Resource.Id.btnApproveDescription).Click += BtnApproveDescription_Click;
            order = JsonConvert.DeserializeObject <Order>(Intent.GetStringExtra("OrderDetails"));
            selectedWorkerList      = order.WorkByUsers.ToList();
            selectedServiceList     = order.ContainsServices?.ToList();
            selectedVehiclePartList = order.UsedVehicleParts.ToList();

            int permissionId = applicationSessionService.GetUserFromApplicationSession().PermissionId;

            if ((PermissionId)permissionId == PermissionId.Admin || (PermissionId)permissionId == PermissionId.SuperAdmin)
            {
                userReceiverId = vehicleService.GetUserIdOwnerByVehicleId(order.VehicleId);
                FindViewById <TextView>(Resource.Id.tvOrderStatusNameLabel).Visibility          = ViewStates.Gone;
                FindViewById <TextView>(Resource.Id.tvOrderStatusName).Visibility               = ViewStates.Gone;
                FindViewById <TextView>(Resource.Id.tvOrderStatusNameLabelForWorker).Visibility = ViewStates.Visible;
                FindViewById <TextView>(Resource.Id.btnAddDescription).Visibility               = ViewStates.Visible;

                Spinner spinnerOrderStatusNameForWorker = FindViewById <Spinner>(Resource.Id.spinnerOrderStatusNameForWorker);
                spinnerOrderStatusNameForWorker.Visibility = ViewStates.Visible;
                orderStatusList = orderStatusService.GetAllOrderStatusList().ToList();
                var orderStatusAdapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerItem, orderStatusList.Select(os => os.Name).ToList());
                orderStatusAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
                spinnerOrderStatusNameForWorker.Adapter       = orderStatusAdapter;
                spinnerOrderStatusNameForWorker.ItemSelected += SpinnerOrderStatusNameForWorker_ItemSelected;

                if ((PermissionId)permissionId == PermissionId.SuperAdmin)
                {
                    FindViewById <TextView>(Resource.Id.tvWorkByUsersLabel).Visibility = ViewStates.Gone;
                    FindViewById <TextView>(Resource.Id.tvWorkByUsers).Visibility      = ViewStates.Gone;
                    Button btnAddWorker = FindViewById <Button>(Resource.Id.btnAddWorker);
                    btnAddWorker.Visibility = ViewStates.Visible;
                    btnAddWorker.Click     += BtnAddWorker_Click;
                }
            }
            else
            {
                userReceiverId = order.WorkByUsers.FirstOrDefault()?.UserId ?? 1;
            }

            CompleteData();
        }
Beispiel #6
0
 private void RefreshGvOrderByWorkerList(ListView lvOrderByWorkerList)
 {
     orderByWorkerList = orderService.GetOrderListByWorker(applicationSessionService.GetUserFromApplicationSession().UserId)
                         .ToList();
     lvOrderByWorkerList.Adapter = new OrderAdapter(this, orderByWorkerList.ToList(), true);
 }