示例#1
0
        public IActionResult NewSpecialty()
        {
            LocationAddEditViewModel locationAddEditViewModel = new LocationAddEditViewModel();

            locationAddEditViewModel.location      = null;
            locationAddEditViewModel.locationTypes = GetLocationTypes();

            return(View("AddEditLocation", locationAddEditViewModel));
        }
        public AddEditLocationView(CrudFlags crudFlag, Func <LocationViewModel> bindData)
        {
            InitializeComponent();
            ViewModel = new LocationAddEditViewModel(this.Navigation);
            ViewModel.CurrentCrudFlag = crudFlag;
            if (bindData != null)
            {
                ViewModel.InitDataBind(bindData);
            }

            BindingContext = ViewModel;
        }
示例#3
0
        public ActionResult Edit(string id)
        {
            string token = HttpContext.Session.GetString("access_token");

            List <LocationModel> locations = APIservice.GetListById <LocationModel>(id, "synapsenamespace=core&synapseentityname=location&synapseattributename=location_id&attributevalue=", token);

            LocationAddEditViewModel locationAddEditViewModel = new LocationAddEditViewModel();

            locationAddEditViewModel.location      = locations.Select(s => s).FirstOrDefault();
            locationAddEditViewModel.locationTypes = GetLocationTypes();

            return(View("AddEditLocation", locationAddEditViewModel));
        }
示例#4
0
        public ActionResult SaveLocation(LocationAddEditViewModel locationAddEditViewModel)
        {
            string token = HttpContext.Session.GetString("access_token");

            string sql = string.Empty;

            locationAddEditViewModel.location.locationtypetext = GetLocationTypes().Where(lt => lt.locationtypecode ==
                                                                                          locationAddEditViewModel.location.locationtypecode).Select(lt => lt.locationtypetext).FirstOrDefault();

            if (locationAddEditViewModel.location.location_id is null)
            {
                List <LocationModel> locations = APIservice.GetListById <LocationModel>(locationAddEditViewModel.location.locationcode, "synapsenamespace=core&synapseentityname=location&synapseattributename=locationcode&attributevalue=", token);

                if (locations.Count > 0)
                {
                    this.toastNotification.AddErrorToastMessage("Location Code already exists.");

                    locationAddEditViewModel.location      = null;
                    locationAddEditViewModel.locationTypes = GetLocationTypes();

                    return(View("AddEditLocation", locationAddEditViewModel));
                }

                locationAddEditViewModel.location.location_id = System.Guid.NewGuid().ToString();
            }

            locationAddEditViewModel.location.statustext = locationAddEditViewModel.location.statuscode;

            string result = APIservice.PostObject <LocationModel>(locationAddEditViewModel.location, "synapsenamespace=core&synapseentityname=location", token);

            if (result == "OK")
            {
                this.toastNotification.AddSuccessToastMessage("Location is successfully saved.");
            }
            else
            {
                this.toastNotification.AddErrorToastMessage("Error while saving Location.");
            }

            locationAddEditViewModel.locationTypes = GetLocationTypes();

            return(View("AddEditLocation", locationAddEditViewModel));
        }