Example #1
0
        protected override void OnInitComplete(EventArgs e)
        {
            if (Request.Cookies[REPO_PROJECT_NAME_COOKIE] != null)
            {
                if (Request.Cookies[REPO_PROJECT_NAME_COOKIE][REPO_COOKIE] != null)
                {
                    string repo = Request.Cookies[REPO_PROJECT_NAME_COOKIE][REPO_COOKIE];

                    if (repo == "RepoTextFile")
                    {
                        manager = new PersonBusiness(new RepoTextFile());
                        MasterPage master = (MasterPage)this.Page.Master;
                        Label      lbl    = (Label)master.FindControl("lblRepoInfo");
                        lbl.Text = "Repository - TextFile";
                    }

                    else
                    {
                        manager = new PersonBusiness(new RepoDatabase());
                        MasterPage master = (MasterPage)this.Page.Master;
                        Label      lbl    = (Label)master.FindControl("lblRepoInfo");
                        lbl.Text = "Repository - DataBase";
                    }
                }
            }

            base.OnInitComplete(e);
        }
        public ActionResult Edit(PersonModel personModel)
        {
            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("Error", "Try Again");
            }
            var pModel = pb.Find(personModel.Id);

            using (var pBus = new PersonBusiness()) {
                if (pModel == null)
                {
                    return(RedirectToAction("Index"));
                }
                if (personModel.FileUpload != null)
                {
                    using (var ms = new MemoryStream())
                    {
                        personModel.FileUpload.InputStream.CopyTo(ms);
                        var array = ms.GetBuffer();
                        personModel.Base64String = Convert.ToBase64String(array);
                    }
                }

                pModel = pBus.Update(personModel);

                return(RedirectToAction("Details/" + pModel.Id));
            }
        }
        public ActionResult Create(PersonModel person)
        {
            var pBus = new PersonBusiness();

            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("Error", "Error Please Try Again !");
                using (pBus)
                {
                    return(View(person));
                }
            }
            if (person.FileUpload != null)
            {
                using (var ms = new MemoryStream())
                {
                    person.FileUpload.InputStream.CopyTo(ms);
                    var array = ms.GetBuffer();
                    person.Base64String = Convert.ToBase64String(array);
                }
            }
            int id = pBus.SavePerson(person);

            return(RedirectToAction("Details/" + id));
        }
        public void Add(PersonBusiness person)
        {
            var entity = PersonMapper.Map(person);

            databaseContext.Person.Add(entity);
            databaseContext.SaveChanges();
        }
        private async void button_Click(object sender, RoutedEventArgs e)
        {
            var person = new PersonModel(Name.Text, Email.Text, Phone.Text);
            var validation = new PersonBusiness();
            var validate = validation.ValidatePerson(person);

            if (validate.isValid)
            {
                var loadExistingData = await ApplicationUtilities.GetSavedUsers();
                var storageHelper = new StorageHelper<List<PersonModel>>(StorageType.Local);

                if (loadExistingData == null)
                {
                    var peopleList = new List<PersonModel> {person};
                    storageHelper.SaveASync(peopleList, "Settings");
                }
                else
                {
                    loadExistingData.Add(person);
                    storageHelper.SaveASync(loadExistingData, "Settings");
                }
                ErrorText.Text = "Saved...";
                ClearUserEntry();
            }
            else
            {
                ErrorText.Text = validate.errorMessage;                 
            }
                
        }
Example #6
0
        public HttpResponseMessage Post(CoupleDTO coupleDto)
        {
            var personPartner = new PersonBusiness()
            {
                FirstName = coupleDto.FirstNamePartner,
                LastName  = coupleDto.LastNamePartner,
                CI        = coupleDto.IdPartner,
                Telephone = coupleDto.TelephonePartner,
                Direction = coupleDto.AddressPartner,
                Mail      = coupleDto.MailPartner
            };
            var person = new PersonBusiness()
            {
                FirstName = coupleDto.FirstName,
                LastName  = coupleDto.LastName,
                CI        = coupleDto.Id,
                Telephone = coupleDto.Telephone,
                Direction = coupleDto.Address,
                Mail      = coupleDto.Mail
            };

            var presentList = new PresentListBusiness()
            {
                Quantity = 25
            };

            int IDPersonPartner = _personService.AddPerson(personPartner);
            int IDPerson        = _personService.AddPerson(person);
            int IDPresentList   = _presentListService.Add(presentList);


            var couple = new CoupleBusiness()
            {
                WeddingDate   = coupleDto.WeddingDate,
                DeliveryDate  = coupleDto.DeliveryDate,
                Address       = coupleDto.AddressDelivery,
                HusbandID     = IDPersonPartner,
                WifeID        = IDPerson,
                PresentListID = IDPresentList,
                Latitude      = coupleDto.Latitude,
                Longitude     = coupleDto.Longitude
            };

            int IDCouple = _coupleService.AddCouple(couple);

            var account = new AccountBusiness(person, personPartner, IDCouple);

            _accountService.AddAccount(account);

            AccountDTO accountDTO = new AccountDTO()
            {
                Account          = account.Name,
                Password         = account.Password,
                FirstName        = person.FirstName,
                FirstNamePartner = personPartner.FirstName
            };

            return(Request.CreateResponse(HttpStatusCode.OK, accountDTO));
        }
 public PersonController(UserManager <ApplicationUser> userManager,
                         IHttpContextAccessor httpContextAccessor,
                         MardisContext mardisContext,
                         ILogger <PersonController> logger,
                         ILogger <ServicesFilterController> loggeFilter) :
     base(userManager, httpContextAccessor, mardisContext, logger)
 {
     personBusiness = new PersonBusiness(mardisContext);
 }
        public void Update(PersonBusiness person)
        {
            var entity = databaseContext.Person.Find(person.Id);

            if (entity != null)
            {
                entity = PersonMapper.Map(person);
                databaseContext.SaveChanges();
            }
        }
Example #9
0
        public void CreatePerson(string firstname, string lastname, DateTime birthDate)
        {
            LoginData.ConnectionString = ConfigurationManager.ConnectionStrings["PXLDB"].ConnectionString;
            LoginData.LoginSuccessFul  = true;
            PersonBusiness persBusiness = new PersonBusiness();// connection);
            PersDto        persDto      = new PersDto();

            persDto.FirstName = firstname;
            persDto.Name      = lastname;
            persDto.BirthDate = birthDate;
            persBusiness.CreatePerson(persDto);
        }
Example #10
0
        public JsonResult GetPersonData(int userID)
        {
            LoginData.ConnectionString = ConfigurationManager.ConnectionStrings["PXLDB"].ConnectionString;
            LoginData.LoginSuccessFul  = true;
            PersonBusiness persBusiness = new PersonBusiness();
            PersDto        persDtos     = persBusiness.GetUserDto(userID);
            JsonResult     json         = new JsonResult();

            json.Data = persDtos;
            json.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            return(json);
        }
Example #11
0
        public int AddPerson(PersonBusiness personBusiness)
        {
            var person = new Person()
            {
                CI        = personBusiness.CI,
                Direction = personBusiness.Direction,
                FirstName = personBusiness.FirstName,
                LastName  = personBusiness.LastName,
                Mail      = personBusiness.Mail,
                Telephone = personBusiness.Telephone
            };

            return(_personRepository.Add(person));
        }
 public IActionResult Post([FromBody] PersonBusiness value)
 {
     try
     {
         using (var db = My.ConnectionFactory())
         {
             int result = db.Execute($@"IF EXISTS({My.Table_PersonBusiness.SelectSingle}) {My.Table_PersonBusiness.Update} ELSE {My.Table_PersonBusiness.Insert}", value);
         }
         return(Ok());
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Example #13
0
        public MainViewModel()
        {
            ListaPrincipal = new ListView();



            _personBusiness            = new PersonBusiness();
            People                     = _personBusiness.GetPeople();
            ListaAux                   = People;
            ListaPrincipal.ItemsSource = People;
            ListViewClicked            = new Command(() =>
            {
                Global.PersonSelected = PersonSelected;
                MessagingCenter.Send <PersonModel>(PersonSelected, "ShowDetail");
            });
        }
Example #14
0
        public DetailViewModel()
        {
            PersonSelected  = Global.PersonSelected;
            _personBusiness = new PersonBusiness();

            ReportClicked = new Command(() =>
            {
                if (PersonSelected.ReportUrl != null)
                {
                    Device.OpenUri(new System.Uri(PersonSelected.ReportUrl));
                }
                else
                {
                }
            });
        }
Example #15
0
 public HttpResponseMessage GetByMelliCode(string code)
 {
     try
     {
         var person = PersonBusiness.GetByBarcode(code);
         return(Request.CreateResponse(HttpStatusCode.OK, person));
     }
     catch (UIValidationExceptions ex)
     {
         this.exceptionHandler.ApiHandleException("PersonController", ex);
         return(Request.CreateResponse(HttpStatusCode.NotFound, ex.ExceptionList.Count > 0 ? ex.ExceptionList[0].Message : ex.Message));
     }
     catch (Exception ex)
     {
         this.exceptionHandler.ApiHandleException("PersonController", ex);
         return(Request.CreateResponse(HttpStatusCode.NotFound, ex.Message));
     }
 }
        public HttpResponseMessage Edit(decimal id, OverTimeProxy viewModel)
        {
            try
            {
                decimal ManagerPersonId;
                if (viewModel.ManagerPersonId == 0)
                {
                    ManagerPersonId = BUser.CurrentUser.Person.ID;
                }
                else
                {
                    ManagerPersonId = viewModel.ManagerPersonId;
                }
                //------------------------------------------------------------------------
                Person person = PersonBusiness.GetByID(ManagerPersonId);
                //تشخیص اینکه طرف معاون هست یا خیر - جهت اعمال محدودیت زمان بندی تایید به تفکیک مدیران و معاونین
                ApprovalScheduleType approvalType = ApprovalScheduleType.Manager;

                var  personParamAssistance = person.PersonTASpec.GetParamValue(person.ID, "IsAssistance", DateTime.Now);
                bool stateAssistance       = personParamAssistance != null?Utility.ToInteger(personParamAssistance.Value) > 0 : false;

                if (stateAssistance)
                {
                    approvalType = ApprovalScheduleType.Assistance;
                }

                OverTimePersonDetailBusiness.UpdateOverTimePersonDetail(id, viewModel, approvalType, ManagerPersonId);
                return(Request.CreateResponse(HttpStatusCode.OK, viewModel));
            }
            catch (UIValidationExceptions ex)
            {
                this.exceptionHandler.ApiHandleException("OverTimePersonController", ex);
                return(Request.CreateResponse(HttpStatusCode.NotFound, ex.ExceptionList.Count > 0 ? ex.ExceptionList[0].Message : ex.Message));
            }
            catch (Exception ex)
            {
                this.exceptionHandler.ApiHandleException("OverTimePersonController", ex);
                return(Request.CreateResponse(HttpStatusCode.NotFound, ex.Message));
            }
        }
Example #17
0
 public PersonsController(PersonBusiness personBusiness)
 {
     _personBusiness = personBusiness;
 }
Example #18
0
        public bool Confirm()
        {
            try
            {
                if (EventSituation == null)
                {
                    ShowMessage("Selecione a situação");
                }
                else
                {
                    DispositionCodeModel dispositionCode = GetDispositionCode();
                    if (dispositionCode != null && !string.IsNullOrEmpty(dispositionCode.Id))
                    {
                        if (!IsSubmitted)
                        {
                            if (EventSituation == EventSituationEnum.NotFound)
                            {
                                VictimData = new VictimModel();
                            }
                            else
                            {
                                if (AsExpected == false)
                                {
                                    if (string.IsNullOrEmpty(VictimData.SituationFound.Key))
                                    {
                                        ShowMessage("Favor selecionar a situação encontrada.");

                                        return(false);
                                    }
                                }
                                else
                                {
                                    VictimData.SituationFound = new KeyValuePair <string, string>();
                                }
                            }

                            SubmissionBusiness.ExecuteCadUpdates(UnitId, AgencyEventId, EventSituation.Value, dispositionCode, Remarks, SelectedHospital, VictimData);
                        }
                        else
                        {
                            if (string.IsNullOrEmpty(VictimData.Name.Trim()))
                            {
                                ShowMessage("Favor inserir o nome da vítima.");

                                return(false);
                            }

                            if (VictimData.Age != null)
                            {
                                if (VictimData.AgeType == null || VictimData.AgeType == 0)
                                {
                                    ShowMessage("Favor selecionar um tipo de idade válido para a vítima.");

                                    return(false);
                                }
                            }

                            if (VictimData.AgeType != null && VictimData.AgeType.Value > 0)
                            {
                                if (VictimData.Age == null)
                                {
                                    ShowMessage("Favor informar uma idade válida para a vítima.");

                                    return(false);
                                }
                            }

                            if (AsExpected == false)
                            {
                                if (string.IsNullOrEmpty(VictimData.SituationFound.Key))
                                {
                                    ShowMessage("Favor selecionar a situação encontrada.");

                                    return(false);
                                }
                            }
                            else
                            {
                                VictimData.SituationFound = new KeyValuePair <string, string>();
                            }

                            string selectedHospitalName = SelectedHospital != null ? SelectedHospital.Name : string.Empty;
                            SubmissionBusiness.ExecuteCadEndUpdates(UnitId, AgencyEventId, EventSituation.Value, dispositionCode, Remarks, selectedHospitalName, HospitalHasChanged, VictimData, IsRetainedStretcherSituation);
                        }

                        SubmissionBusiness.SaveSubmission(UnitId, AgencyEventId, dispositionCode, AsExpected, SelectedHospital, Remarks, VictimData);

                        if (!HasNotRetainedStretcher && !IsRetainedStretcherSituation)
                        {
                            UserModel currentUser = PersonBusiness.GetCurrentUser();
                            RetainedStretcherBusiness.ComeBackUnitStatusToRetainedStretcher(UnitId, currentUser);
                        }

                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error("Add/In.: Falha na finalização, Submission.", ex);

                ShowMessage("Falha ao realizar solicitação.");
            }

            return(false);
        }