Exemplo n.º 1
0
        public ActionResult DeletePost(PersonDocument vm)
        {
            List <LogTypeViewModel> LogList = new List <LogTypeViewModel>();

            LogList.Add(new LogTypeViewModel
            {
                ExObj = vm,
            });

            _PersonDocumentService.Delete(vm.PersonDocumentID);
            XElement Modifications = new ModificationsCheckService().CheckChanges(LogList);

            try
            {
                _unitOfWork.Save();
            }

            catch (Exception ex)
            {
                string message = _exception.HandleException(ex);
                ModelState.AddModelError("", message);
                return(PartialView("EditSize", vm));
            }

            LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
            {
                DocTypeId       = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.PersonDocument).DocumentTypeId,
                DocId           = vm.PersonDocumentID,
                ActivityType    = (int)ActivityTypeContants.Deleted,
                xEModifications = Modifications,
            }));

            return(Json(new { success = true }));
        }
        public PersonItemInIndexViewModel(
            PersonDocument personDocument)
        {
            PersonGuid = personDocument.PersonGuid;
            Gender     = personDocument.Gender;

            if (personDocument.Names.Any())
            {
                Names = personDocument.Names;
            }

            if (personDocument.YearOfBirth != null)
            {
                YearOfBirth = personDocument.YearOfBirth.ToString();
            }

            if (personDocument.YearOfDeath != null)
            {
                YearOfDeath = personDocument.YearOfDeath.ToString();
            }

            if (personDocument.Age != null)
            {
                Age = personDocument.Age.ToString();
            }
        }
Exemplo n.º 3
0
        public ActionResult _Create(int Id) //Id ==>Sale Order Header Id
        {
            PersonDocument s = new PersonDocument();

            s.PersonId = Id;
            PrepareViewBag(null);
            return(PartialView("_Create", s));
        }
Exemplo n.º 4
0
        public ActionResult UpdateProfilePhoto(HttpPostedFileBase imageFile)
        {
            var           fs                 = Request.Files;
            var           file               = fs[0];
            var           fileExtension      = Path.GetExtension(file.FileName);
            List <string> acceptedExtensions = new List <string> {
                ".jpg", ".png", ".gif", ".jpeg"
            };

            if (fileExtension != null && !acceptedExtensions.Contains(fileExtension.ToLower()))
            {
                return(new JsonCamelCaseResult(new { Success = false, Message = "Supported file types are *.jpg, *.png, *.gif, *.jpeg" }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                var fileName     = Path.GetFileName(file.FileName);
                var index        = fileName.LastIndexOf(".");
                var newFileName  = fileName.Insert(0, $"{Guid.NewGuid()}");
                var physicalPath = Path.Combine(Server.MapPath("~/images"), newFileName);
                file.SaveAs(physicalPath);

                var ProfilePhoto = _personDocumentRepository.Get(x => x.PersonId == _appContext.LoginId && x.Status == 1 && x.DocumentType == 1).FirstOrDefault();

                try
                {
                    if (ProfilePhoto == null)
                    {
                        var newProfilePhoto = new PersonDocument
                        {
                            PersonId     = _appContext.LoginId,
                            Status       = 1,
                            FileName     = newFileName,
                            CreatedDate  = DateTime.Now,
                            CreatedBy    = _appContext.LoginId,
                            ModifiedDate = DateTime.Now,
                            ModifiedBy   = _appContext.LoginId,
                            DocumentType = 1
                        };

                        _personDocumentRepository.Add(newProfilePhoto);
                    }
                    else
                    {
                        ProfilePhoto.FileName     = newFileName;
                        ProfilePhoto.ModifiedBy   = _appContext.LoginId;
                        ProfilePhoto.ModifiedDate = DateTime.Now;

                        _personDocumentRepository.Update(ProfilePhoto);
                    }

                    return(new JsonCamelCaseResult(new { Success = true, newProfilePhotoName = newFileName }, JsonRequestBehavior.AllowGet));
                }
                catch (Exception e)
                {
                    return(new JsonCamelCaseResult(new { Success = false, Message = "Error while uploading Profile Photo" }, JsonRequestBehavior.AllowGet));
                }
            }
        }
Exemplo n.º 5
0
        public async Task <IActionResult> CreateUser([FromBody] PersonDocument doc)
        {
            var data = _faceClient.CreatePersonAsync(_personGroupKey, doc.Name);

            doc.PersonId = data.Result.PersonId;
            doc.Created  = DateTime.Now;
            doc.Id       = ObjectId.GenerateNewId().ToString();
            await _db.Persons.InsertOneAsync(doc);

            return(this.Json(doc));
        }
Exemplo n.º 6
0
        public ActionResult DeleteConfirmed(int id)
        {
            PersonDocument PersonDocument = _PersonDocumentService.Find(id);

            _PersonDocumentService.Delete(id);


            _unitOfWork.Save();

            return(RedirectToAction("Index", new { Id = PersonDocument.PersonId }).Success("Data deleted successfully"));
        }
Exemplo n.º 7
0
        public ActionResult _Edit(int id)
        {
            PersonDocument temp = _PersonDocumentService.GetPersonDocument(id);

            PrepareViewBag(temp);

            if (temp == null)
            {
                return(HttpNotFound());
            }
            return(PartialView("_Create", temp));
        }
Exemplo n.º 8
0
        private static async Task SavePerson(IDocumentRepository repository, string firstName, string lastName)
        {
            var person = new PersonDocument
            {
                FirstName = firstName,
                LastName = lastName
            };

            await repository.Save(person);

            System.Console.WriteLine("Created person {0} {1}", firstName, lastName);
        }
Exemplo n.º 9
0
        public ActionResult Delete(int id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PersonDocument PersonDocument = _PersonDocumentService.Find(id);

            if (PersonDocument == null)
            {
                return(HttpNotFound());
            }
            return(View(PersonDocument));
        }
        public void TestPersonDocumentSearch()
        {
            var client = new PersonServiceClient();

            var searchCriteria = new PersonDocument();
            searchCriteria.State = "NY";

            var pageOfListPersonDocuments = client.SearchPersons(1, 10, "lastname", SortDirection.Ascending, searchCriteria);
            client.Close();

            // Verify that only 10 records or less are returned
            Assert.IsTrue(pageOfListPersonDocuments.Data.Count <= 10);

            // Verify that only NY state record are returned
            foreach (PersonDocument personDoc in pageOfListPersonDocuments.Data)
                Assert.AreEqual(personDoc.State, "NY");
        }
Exemplo n.º 11
0
        public void TestPersonDocumentSearch()
        {
            var uowFactory          = new FootlooseFSSqlUnitOfWorkFactory();
            var notificationService = new FootlooseFSNotificationService();
            var service             = new FootlooseFSService(uowFactory, notificationService);

            var searchCriteria = new PersonDocument();

            searchCriteria.State = "NY";

            var pageOfListPersonDocuments = service.SearchPersonDocuments(1, 10, "LastName", SortDirection.Ascending, searchCriteria);

            // Verify that only 10 records or less are returned
            Assert.IsTrue(pageOfListPersonDocuments.Data.Count <= 10);

            // Verify that only NY state record are returned
            Assert.IsFalse(pageOfListPersonDocuments.Data.Any(p => p.State != "NY"));
        }
        public void TestPersonDocumentSearch()
        {
            var client = new PersonServiceClient();

            var searchCriteria = new PersonDocument();

            searchCriteria.State = "NY";

            var pageOfListPersonDocuments = client.SearchPersons(1, 10, "lastname", SortDirection.Ascending, searchCriteria);

            client.Close();

            // Verify that only 10 records or less are returned
            Assert.IsTrue(pageOfListPersonDocuments.Data.Count <= 10);

            // Verify that only NY state record are returned
            foreach (PersonDocument personDoc in pageOfListPersonDocuments.Data)
            {
                Assert.AreEqual(personDoc.State, "NY");
            }
        }
Exemplo n.º 13
0
        private IEnumerable <PersonDocument> GenerateDocuments(int enumerable)
        {
            var result = new List <PersonDocument>();

            Parallel.For(0, enumerable, i => {
                var doc = new PersonDocument()
                {
                    Id             = Guid.NewGuid(),
                    LastChangeDate = DateTime.Now,
                    RegisterDate   = DateTime.Now,
                    Status         = core.fieldType.RecordStatus.Active,
                    Type           = Faker.RandomNumber.Next(6).ToString(),
                };

                if (doc.Type.ToString() == "0")
                {
                    doc.Value = Faker.Identification.MedicareBeneficiaryIdentifier();
                }
                else if (doc.Type.ToString() == "1")
                {
                    doc.Value = Faker.Identification.SocialSecurityNumber();
                }
                else if (doc.Type.ToString() == "2")
                {
                    doc.Value = Faker.Identification.UkNationalInsuranceNumber();
                }
                else if (doc.Type.ToString() == "3")
                {
                    doc.Value = Faker.Identification.UkPassportNumber();
                }
                else
                {
                    doc.Value = Faker.Identification.UsPassportNumber();
                }

                result.Add(doc);
            });

            return(result);
        }
Exemplo n.º 14
0
        private string serializePersonToPersonDocumentJson(Person person)
        {
            var personDocument = new PersonDocument();

            personDocument.PersonID     = person.PersonID;
            personDocument.EmailAddress = person.EmailAddress;
            personDocument.FirstName    = person.FirstName;
            personDocument.LastName     = person.LastName;
            personDocument.PhoneNumber  = person.Phones.Any(p => p.PhoneTypeID == 1) ? person.Phones.First(p => p.PhoneTypeID == 1).Number : string.Empty;

            var address = person.Addresses.Any(a => a.AddressTypeID == 1) ? person.Addresses.First(a => a.AddressTypeID == 1).Address : null;

            if (address != null)
            {
                personDocument.StreetAddress = address.StreetAddress;
                personDocument.City          = address.City;
                personDocument.State         = address.State;
                personDocument.Zip           = address.Zip;
            }

            return(JsonConvert.SerializeObject(personDocument));
        }
Exemplo n.º 15
0
        public AccountDocument GetTransformedDocument(TradingAccountPayload payload, List <SyncFeedEntryLink> links)
        {
            AccountDocument    document       = new AccountDocument();
            tradingAccounttype tradingAccount = payload.TradingAccount;

            document.addresses = new AddressDocumentCollection();
            if (tradingAccount.postalAddresses != null && tradingAccount.postalAddresses != null)
            {
                foreach (postalAddresstype postalAddress in tradingAccount.postalAddresses)
                {
                    PostalAddressPayload postalAdressPayload = new PostalAddressPayload();
                    postalAdressPayload.PostalAddresstype = postalAddress;
                    postalAdressPayload.SyncUuid          = StringToGuid(postalAddress.uuid);
                    AddressDocument address = _postalAdressTransformation.GetTransformedDocument(postalAdressPayload, Helper.ReducePayloadPath(links));
                    document.addresses.Add(address);
                }
            }
            bool hasMainAdress = false;

            for (int index = 0; index < document.addresses.documents.Count; index++)
            {
                AddressDocument address = document.addresses.documents[index] as AddressDocument;
                if ((address.primaryaddress.Value != null) && (address.primaryaddress.Value.ToString().Equals("true", StringComparison.InvariantCultureIgnoreCase)))
                {
                    hasMainAdress = true;
                }
            }
            if ((!hasMainAdress) && (document.addresses.documents.Count > 0))
            {
                AddressDocument address = document.addresses.documents[0] as AddressDocument;
                address.primaryaddress.Value = "true";
            }
            if (String.IsNullOrEmpty(payload.LocalID))
            {
                document.CrmId = payload.SyncUuid.ToString();//
                document.Id    = GetLocalId(payload.SyncUuid);
            }
            else
            {
                document.Id = payload.LocalID;
            }
            document.currencyid.Value = tradingAccount.currency;
            document.emails           = new EmailsDocumentCollection();
            if (tradingAccount.emails != null && tradingAccount.emails != null)
            {
                foreach (emailtype email in tradingAccount.emails)
                {
                    EmailPayload emailPayload = new EmailPayload();
                    emailPayload.Emailtype = email;
                    emailPayload.SyncUuid  = StringToGuid(email.uuid);
                    EmailDocument emailDocument = _emailAdressTransformation.GetTransformedDocument(emailPayload, Helper.ReducePayloadPath(links));
                    document.emails.Add(emailDocument);
                }
            }
            document.name.Value = tradingAccount.name;
            // ????? document.onhold
            document.people = new PeopleDocumentCollection();
            if (tradingAccount.contacts != null && tradingAccount.contacts != null)
            {
                foreach (contacttype contact in tradingAccount.contacts)
                {
                    ContactPayload contactPayload = new ContactPayload();
                    contactPayload.Contacttype = contact;
                    contactPayload.SyncUuid    = StringToGuid(contact.uuid);
                    PersonDocument person = _contactTransformation.GetTransformedDocument(contactPayload, Helper.ReducePayloadPath(links));
                    document.people.Add(person);
                }
            }
            bool hasMainPerson = false;

            for (int index = 0; index < document.people.documents.Count; index++)
            {
                PersonDocument person = document.people.documents[index] as PersonDocument;
                if ((person.primaryperson.Value != null) && (person.primaryperson.Value.ToString().Equals("true", StringComparison.InvariantCultureIgnoreCase)))
                {
                    hasMainPerson = true;
                }
            }
            if ((!hasMainPerson) && (document.people.documents.Count > 0))
            {
                PersonDocument person = document.people.documents[0] as PersonDocument;
                person.primaryperson.Value = "true";
            }

            document.phones = new PhonesDocumentCollection();
            if (tradingAccount.phones != null && tradingAccount.phones != null)
            {
                foreach (phoneNumbertype phoneNumber in tradingAccount.phones)
                {
                    PhoneNumberPayload phoneNumberPayload = new PhoneNumberPayload();
                    phoneNumberPayload.PhoneNumbertype = phoneNumber;
                    //phoneNumberPayload.SyncUuid = GetUuid(phoneNumber.applicationID);
                    PhoneDocument phone = _phoneNumberTransformation.GetTransformedDocument(phoneNumberPayload, Helper.ReducePayloadPath(links));
                    document.phones.Add(phone);
                }
            }
            document.customerSupplierFlag.Value = tradingAccount.customerSupplierFlag;
            return(document);
        }
Exemplo n.º 16
0
        public TradingAccountPayload GetTransformedPayload(AccountDocument document, out List <SyncFeedEntryLink> links)
        {
            links = new List <SyncFeedEntryLink>();
            TradingAccountPayload payload        = new TradingAccountPayload();
            tradingAccounttype    tradingAccount = new tradingAccounttype();

            tradingAccount.accountingType       = tradingAccountAccountingTypeenum.Unknown;
            tradingAccount.customerSupplierFlag = (document.customerSupplierFlag.IsNull) ? null : document.customerSupplierFlag.Value.ToString();
            tradingAccount.active = true;
            //tradingAccount.postalAddresses = new postalAddresstype[0]();
            //tradingAccount.contacts = new contacttype[0]();
            //tradingAccount.phones = new phoneNumbertype[0]();
            tradingAccount.deleted         = false;
            tradingAccount.deliveryContact = null;
            tradingAccount.deliveryMethod  = null;
            tradingAccount.deliveryRule    = false;
            //tradingAccount.emails = new emailtype[0]();
            tradingAccount.applicationID = document.Id;
            payload.SyncUuid             = GetUuid(document.Id, document.CrmId);
            payload.LocalID      = document.Id;
            tradingAccount.uuid  = payload.SyncUuid.ToString();
            tradingAccount.label = SupportedResourceKinds.tradingAccounts.ToString();
            tradingAccount.name  = (document.name.IsNull) ? null : document.name.Value.ToString();


            //Many more things should set to default values


            // adresses
            int adressCount = document.addresses.documents.Count;

            tradingAccount.postalAddresses = new postalAddresstype[adressCount];
            for (int index = 0; index < adressCount; index++)
            {
                List <SyncFeedEntryLink> addressLinks;
                AddressDocument          address = document.addresses.documents[index] as AddressDocument;
                PostalAddressPayload     postalAdressPayload;
                postalAdressPayload = _postalAdressTransformation.GetTransformedPayload(address, out addressLinks);
                tradingAccount.postalAddresses[index] = postalAdressPayload.PostalAddresstype;
                links.Add(SyncFeedEntryLink.CreateRelatedLink(
                              Common.ResourceKindHelpers.GetSingleResourceUrl(
                                  _context.DatasetLink, SupportedResourceKinds.postalAddresses.ToString(), postalAdressPayload.LocalID),
                              "postalAddresses",
                              "postalAddresses[" + index.ToString() + "]",
                              postalAdressPayload.SyncUuid.ToString()));
            }

            //emails
            int emailsCount = document.emails.documents.Count;

            tradingAccount.emails = new emailtype[emailsCount];
            for (int index = 0; index < emailsCount; index++)
            {
                List <SyncFeedEntryLink> emailLinks;
                EmailDocument            email = document.emails.documents[index] as EmailDocument;
                EmailPayload             EmailPayload;
                EmailPayload = _emailAdressTransformation.GetTransformedPayload(email, out emailLinks);
                tradingAccount.emails[index] = EmailPayload.Emailtype;

                links.Add(SyncFeedEntryLink.CreateRelatedLink(
                              Common.ResourceKindHelpers.GetSingleResourceUrl(
                                  _context.DatasetLink, SupportedResourceKinds.emails.ToString(), EmailPayload.LocalID),
                              "emails",
                              "emails[" + index.ToString() + "]",
                              EmailPayload.SyncUuid.ToString()));
            }


            //phones
            int phonesCount = document.phones.documents.Count;

            tradingAccount.phones = new phoneNumbertype[phonesCount];
            for (int index = 0; index < phonesCount; index++)
            {
                List <SyncFeedEntryLink> phoneLinks;
                PhoneDocument            phone = document.phones.documents[index] as PhoneDocument;
                PhoneNumberPayload       phoneNumberPayload;
                phoneNumberPayload           = _phoneNumberTransformation.GetTransformedPayload(phone, out phoneLinks);
                tradingAccount.phones[index] = phoneNumberPayload.PhoneNumbertype;

                links.Add(SyncFeedEntryLink.CreateRelatedLink(
                              Common.ResourceKindHelpers.GetSingleResourceUrl(
                                  _context.DatasetLink, SupportedResourceKinds.phoneNumbers.ToString(), phoneNumberPayload.LocalID),
                              "phones",
                              "phones[" + index.ToString() + "]",
                              phoneNumberPayload.SyncUuid.ToString()));
            }

            //contacts
            int contactsCount = document.people.documents.Count;

            tradingAccount.contacts = new contacttype[contactsCount];
            for (int index = 0; index < contactsCount; index++)
            {
                List <SyncFeedEntryLink> contactLinks;
                PersonDocument           person = document.people.documents[index] as PersonDocument;
                ContactPayload           contactPayload;
                contactPayload = _contactTransformation.GetTransformedPayload(person, out contactLinks);
                tradingAccount.contacts[index] = contactPayload.Contacttype;
                links.Add(SyncFeedEntryLink.CreateRelatedLink(
                              Common.ResourceKindHelpers.GetSingleResourceUrl(
                                  _context.DatasetLink, SupportedResourceKinds.contacts.ToString(), contactPayload.LocalID),
                              "contacts",
                              "contacts[" + index.ToString() + "]",
                              contactPayload.SyncUuid.ToString()));
            }


            payload.TradingAccount = tradingAccount;

            SyncFeedEntryLink selfLink = SyncFeedEntryLink.CreateSelfLink(String.Format("{0}{1}('{2}')", _datasetLink, SupportedResourceKinds.tradingAccounts, document.Id));

            links.Add(selfLink);
            return(payload);
        }
        /// <summary>
        /// Saves the correct value from ProfileMember into the passed in PersonAttribute.
        /// If the Attribute is a YesNo attribute, then the Attribute for the ProfileMember will be marked as yes.
        /// If the Attribute is a DateTime attribute, then the value will be the DateActive value of the ProfileMember.
        /// If the Attribute is a Lookup, then the value will be the Lookup ID that has a matching Value to the MemberNotes property of the ProfileMember.
        /// If the Attribute is any other type, the value will be the MemberNotes.
        /// </summary>
        /// <param name="personAttribute"></param>
        /// <param name="member"></param>
        private bool SaveAttributeValue(PersonAttribute personAttribute, ProfileMember member, bool overwrite)
        {
            bool updated = false;
            try
            {
                switch (personAttribute.AttributeType)
                {
                    case DataType.YesNo:
                        if (overwrite || !personAttribute.HasIntValue)
                        {
                            personAttribute.IntValue = 1;
                            updated = true;
                        }
                        break;

                    case DataType.DateTime:
                        if (overwrite || !personAttribute.HasDateValue)
                        {
                            personAttribute.DateValue = member.DateActive;
                            updated = true;
                        }
                        break;

                    case DataType.Lookup:
                        if (!string.IsNullOrEmpty(member.MemberNotes.Trim()) && (overwrite || !personAttribute.HasIntValue))
                        {
                            LookupType lt = new LookupType(int.Parse(personAttribute.TypeQualifier));
                            Lookup lookup = lt.Values.SingleOrDefault(l => l.Value.ToUpper() == member.MemberNotes.Trim().ToUpper());
                            if (lookup != null)
                            {
                                personAttribute.IntValue = lookup.LookupID;
                                updated = true;
                            }
                        }
                        break;

                    default:
                        if (overwrite || !personAttribute.HasStringValue)
                        {
                            personAttribute.StringValue = member.MemberNotes.Trim();
                            updated = true;
                        }
                        break;
                }

                if (updated)
                {
                    personAttribute.Save(CurrentOrganization.OrganizationID, "TagsToAttributes");
                    // we must save the relationship between the document and the person
                    if (personAttribute.AttributeType == DataType.Document)
                    {
                        if (personAttribute.IntValue != -1)
                        {
                            PersonDocument newDocument = new PersonDocument(personAttribute.PersonID, personAttribute.IntValue);
                            newDocument.PersonID = personAttribute.PersonID;
                            newDocument.DocumentID = personAttribute.IntValue;
                            newDocument.SaveRelationship("TagsToAttributes");
                        }
                    }
                }

                return updated;
            }
            catch { throw; }
        }
Exemplo n.º 18
0
 public PersonDocument Add(PersonDocument pt)
 {
     _unitOfWork.Repository <PersonDocument>().Insert(pt);
     return(pt);
 }
Exemplo n.º 19
0
 public void Update(PersonDocument pt)
 {
     pt.ObjectState = ObjectState.Modified;
     _unitOfWork.Repository <PersonDocument>().Update(pt);
 }
Exemplo n.º 20
0
        private PageOfList <PersonDocument> createTestData()
        {
            List <PersonDocument> personDocuments = new List <PersonDocument>();

            PersonDocument personDocument = new PersonDocument
            {
                PersonID      = 1,
                FirstName     = "Pam",
                LastName      = "Scicchitano",
                EmailAddress  = "*****@*****.**",
                PhoneNumber   = "336-418-5159",
                StreetAddress = "38 S Dunworth St #4185",
                State         = "NC",
                Zip           = "27215"
            };

            personDocuments.Add(personDocument);

            personDocument = new PersonDocument
            {
                PersonID     = 2,
                FirstName    = "Dominique",
                LastName     = "Marantz",
                EmailAddress = "*****@*****.**",
                PhoneNumber  = "336-418-5159",
                State        = "NC",
                Zip          = "27215"
            };
            personDocuments.Add(personDocument);

            personDocument = new PersonDocument
            {
                PersonID      = 3,
                FirstName     = "Denese",
                LastName      = "Cullars",
                EmailAddress  = "*****@*****.**",
                PhoneNumber   = "336-418-5159",
                StreetAddress = "38 S Dunworth St #4185",
                State         = "NC",
                Zip           = "27215"
            };
            personDocuments.Add(personDocument);

            personDocument = new PersonDocument
            {
                PersonID      = 4,
                FirstName     = "Gaynelle",
                LastName      = "Resetar",
                EmailAddress  = "*****@*****.**",
                PhoneNumber   = "336-418-5159",
                StreetAddress = "38 S Dunworth St #4185",
                State         = "NC",
                Zip           = "27215"
            };
            personDocuments.Add(personDocument);

            personDocument = new PersonDocument
            {
                PersonID      = 5,
                FirstName     = "Melynda",
                LastName      = "Stockton",
                EmailAddress  = "*****@*****.**",
                PhoneNumber   = "336-418-5159",
                StreetAddress = "38 S Dunworth St #4185",
                State         = "NC",
                Zip           = "27215"
            };
            personDocuments.Add(personDocument);

            personDocument = new PersonDocument
            {
                PersonID      = 6,
                FirstName     = "Rubye",
                LastName      = "Humphers",
                EmailAddress  = "*****@*****.**",
                PhoneNumber   = "336-418-5159",
                StreetAddress = "38 S Dunworth St #4185",
                State         = "NC",
                Zip           = "27215"
            };
            personDocuments.Add(personDocument);

            personDocument = new PersonDocument
            {
                PersonID      = 7,
                FirstName     = "Otto",
                LastName      = "Uy",
                EmailAddress  = "*****@*****.**",
                PhoneNumber   = "336-418-5159",
                StreetAddress = "38 S Dunworth St #4185",
                State         = "NC",
                Zip           = "27215"
            };
            personDocuments.Add(personDocument);

            personDocument = new PersonDocument
            {
                PersonID      = 8,
                FirstName     = "Carita",
                LastName      = "Campain",
                EmailAddress  = "*****@*****.**",
                PhoneNumber   = "336-418-5159",
                StreetAddress = "38 S Dunworth St #4185",
                State         = "NC",
                Zip           = "27215"
            };
            personDocuments.Add(personDocument);

            personDocument = new PersonDocument
            {
                PersonID      = 9,
                FirstName     = "Luvenia",
                LastName      = "Safe",
                EmailAddress  = "*****@*****.**",
                PhoneNumber   = "336-418-5159",
                StreetAddress = "38 S Dunworth St #4185",
                State         = "NC",
                Zip           = "27215"
            };
            personDocuments.Add(personDocument);

            personDocument = new PersonDocument
            {
                PersonID      = 10,
                FirstName     = "David",
                LastName      = "ScicMilechitano",
                EmailAddress  = "*****@*****.**",
                PhoneNumber   = "336-418-5159",
                StreetAddress = "38 S Dunworth St #4185",
                State         = "NC",
                Zip           = "27215"
            };
            personDocuments.Add(personDocument);

            PageOfList <PersonDocument> personDocumentPage = new PageOfList <PersonDocument>(personDocuments, pageIndex, pageSize, totalItemCount);

            return(personDocumentPage);
        }
Exemplo n.º 21
0
        public ActionResult UploadFile(HttpPostedFileBase fileName, int documentType)
        {
            var loginId = _appContext.LoginId;
            var login   = _loginRepository.GetQueryable().Where(x => x.Id == loginId).FirstOrDefault();

            if (login == null || login.Person == null)
            {
                ModelState.AddModelError("", "This login is invalid");
                return(RedirectToAction("MyProfile"));
            }

            if (fileName == null)
            {
                ModelState.AddModelError("", "Please select a file to upload");
                return(RedirectToAction("MyProfile"));
            }

            try
            {
                // TODO put it in the service PersonDocumentService
                var allowedExtensions = SiteUtil.AllowedFileExtensions;
                var extension         = Path.GetExtension(fileName.FileName);
                var guid = login.Person.UID;

                if (allowedExtensions.Any(e => e.Equals(extension, StringComparison.InvariantCultureIgnoreCase)))
                {
                    //var newName = "new-name" + extension;
                    var newFileName = GetNewFileName(documentType, loginId, guid) + extension;
                    //string path = Path.Combine(Server.MapPath("~/UploadFiles"), newFileName);
                    string path = Path.Combine(Server.MapPath(SiteUtil.UploadFileDir), newFileName);
                    fileName.SaveAs(path);

                    //save data
                    var personDocument = new PersonDocument
                    {
                        FileName     = newFileName,
                        DocumentType = documentType,
                        CreatedDate  = DateTime.UtcNow,
                        CreatedBy    = loginId,
                        PersonId     = loginId,
                        Status       = (int)DocumentStatus.Processing
                    };
                    _personDocumentRepository.Add(personDocument);

                    // Send notification
                    var docType  = Enum.GetName(typeof(DocumentType), documentType);
                    var fullName = string.Format("{0} {1}", login.Person.FirstName, login.Person.LastName);

                    _emailService.SendUploadDocumentNotification(SiteUtil.UploadDocumentURL, login.Username, SiteUtil.SupportEmail,
                                                                 newFileName, docType, fullName, login.Person.MobilePhone);
                }
                else
                {
                    ModelState.AddModelError("", "Please select a " + string.Join(" ", allowedExtensions.ToArray()) + " file");
                }
            }
            catch (Exception ex)
            {
                Logging.Error(ex.Message, ex);
                ModelState.AddModelError("", "Something went wrong, " +
                                         "our team has been notified with this error.");
            }

            return(RedirectToAction("MyProfile"));
        }
Exemplo n.º 22
0
        public PersonSearchResult SearchPersonNames(
            string searchText,
            string filterText)
        {
            if (string.IsNullOrWhiteSpace(searchText))
            {
                return(new PersonSearchResult());
            }

            using (var indexClient =
                       new SearchIndexClient(
                           _serviceSettings.Value.SearchServiceName,
                           _serviceSettings.Value.SearchIndexClientName,
                           new SearchCredentials(
                               _serviceSettings.Value.PrimaryAdminKeyInAzurePortal)))
            {
                //
                // Search query
                //

                SearchParameters parameters;
                DocumentSearchResult <PersonIndexModel> search;

                parameters =
                    new SearchParameters
                {
                    Facets = new[] { "gender" },
                    //Select = new[] { "names" },
                    //HighlightFields = new[] { "names" },
                    //Filter = "gender eq 'Male'",
                    IncludeTotalResultCount = true
                };

                // Filter
                if (!string.IsNullOrWhiteSpace(filterText))
                {
                    parameters.Filter = filterText;
                }

                search = indexClient.Documents.Search <PersonIndexModel>(searchText, parameters);

                //
                // Map and return results
                //

                var mappedSearchResult = new PersonSearchResult();

                if (search.Count != null)
                {
                    mappedSearchResult.NumberOfItemsInSearchResult = (int)search.Count;
                }

                mappedSearchResult.NumberOfItemsOnThisPage = search.Results.Count;

                // Get persons
                foreach (var result in search.Results)
                {
                    var personDocument = new PersonDocument
                    {
                        PersonGuid  = result.Document.PersonGuid,
                        Gender      = result.Document.Gender,
                        YearOfBirth = result.Document.YearOfBirth,
                        YearOfDeath = result.Document.YearOfDeath,
                        Age         = result.Document.Age
                    };

                    // Get names and create highlights if possible
                    try
                    {
                        foreach (var name in result.Document.Names)
                        {
                            var nameWithHighlight =
                                Regex.Replace(
                                    name,
                                    searchText,
                                    match => "<em>" + match.Value + "</em>",
                                    RegexOptions.Compiled | RegexOptions.IgnoreCase);

                            personDocument.Names.Add(nameWithHighlight);
                        }
                    }
                    catch (ArgumentException)
                    {
                        // If user input contains * then Regex fails.
                        // Then display names without highlights.
                        personDocument.Names = result.Document.Names.ToList();
                    }

                    mappedSearchResult.PersonDocuments.Add(personDocument);
                }

                // Get facets
                if (search.Facets != null &&
                    search.Facets.ContainsKey("gender"))
                {
                    foreach (var facet in search.Facets["gender"])
                    {
                        var newFacet = new SearchFacetItem
                        {
                            Name = facet.Value.ToString()
                        };

                        if (facet.Count != null)
                        {
                            newFacet.Count = (int)facet.Count;
                        }

                        mappedSearchResult
                        .SearchFacetItems
                        .Add(newFacet);
                    }
                }

                return(mappedSearchResult);
            }
        }
        public AccountDocument GetTransformedDocument(TradingAccountFeedEntry feedEntry)
        {
            AccountDocument accountDocument = new AccountDocument();

            #region Postal adresses
            accountDocument.addresses = new AddressDocumentCollection();

            if (feedEntry.postalAddresses != null && feedEntry.postalAddresses != null)
            {
                foreach (PostalAddressFeedEntry postalAdressEntry in feedEntry.postalAddresses.Entries)
                {
                    AddressDocument address = _postalAdressTransformation.GetTransformedDocument(postalAdressEntry);
                    accountDocument.addresses.Add(address);
                }
            }

            bool hasMainAdress = false;
            for (int index = 0; index < accountDocument.addresses.documents.Count; index++)
            {
                AddressDocument address = accountDocument.addresses.documents[index] as AddressDocument;
                if ((address.primaryaddress.Value != null) && (address.primaryaddress.Value.ToString().Equals("true", StringComparison.InvariantCultureIgnoreCase)))
                {
                    hasMainAdress = true;
                }
            }
            if ((!hasMainAdress) && (accountDocument.addresses.documents.Count > 0))
            {
                AddressDocument address = accountDocument.addresses.documents[0] as AddressDocument;
                address.primaryaddress.Value = "true";
            }

            #endregion postal adresses

            if (GuidIsNullOrEmpty(feedEntry.UUID))
            {
                accountDocument.Id = feedEntry.Key;
            }
            else
            {
                accountDocument.CrmId = feedEntry.UUID.ToString();
                accountDocument.Id    = GetLocalId(feedEntry.UUID);
            }

            if (feedEntry.IsPropertyChanged("currency"))
            {
                accountDocument.currencyid.Value = feedEntry.currency;
            }


            #region emails
            accountDocument.emails = new EmailsDocumentCollection();
            if (feedEntry.emails != null)
            {
                foreach (EmailFeedEntry emailEntry in feedEntry.emails.Entries)
                {
                    EmailDocument emailDocument = _emailAdressTransformation.GetTransformedDocument(emailEntry);
                    accountDocument.emails.Add(emailDocument);
                }
            }
            #endregion

            if (feedEntry.IsPropertyChanged("name"))
            {
                accountDocument.name.Value = feedEntry.name;
            }

            // ????? document.onhold

            #region contacts
            accountDocument.people = new PeopleDocumentCollection();
            if (feedEntry.contacts != null)
            {
                foreach (ContactFeedEntry contact in feedEntry.contacts.Entries)
                {
                    PersonDocument person = _contactTransformation.GetTransformedDocument(contact);
                    accountDocument.people.Add(person);
                }
            }
            bool hasMainPerson = false;
            for (int index = 0; index < accountDocument.people.documents.Count; index++)
            {
                PersonDocument person = accountDocument.people.documents[index] as PersonDocument;
                if ((person.primaryperson.Value != null) && (person.primaryperson.Value.ToString().Equals("true", StringComparison.InvariantCultureIgnoreCase)))
                {
                    hasMainPerson = true;
                }
            }
            if ((!hasMainPerson) && (accountDocument.people.documents.Count > 0))
            {
                PersonDocument person = accountDocument.people.documents[0] as PersonDocument;
                person.primaryperson.Value = "true";
            }
            #endregion

            #region phones
            accountDocument.phones = new PhonesDocumentCollection();
            if (feedEntry.phones != null)
            {
                foreach (PhoneNumberFeedEntry phoneNumberPayload in feedEntry.phones.Entries)
                {
                    PhoneDocument phone = _phoneNumberTransformation.GetTransformedDocument(phoneNumberPayload);
                    accountDocument.phones.Add(phone);
                }
            }
            #endregion

            if (feedEntry.IsPropertyChanged("customerSupplierFlag"))
            {
                accountDocument.customerSupplierFlag.Value = Enum.GetName(typeof(supplierFlagenum), feedEntry.customerSupplierFlag);
            }

            return(accountDocument);
        }
        public TradingAccountFeedEntry GetTransformedPayload(AccountDocument document)
        {
            TradingAccountFeedEntry entry = new TradingAccountFeedEntry();

            entry.customerSupplierFlag = GetSupplierFlag(document.customerSupplierFlag);
            entry.active = true;

            entry.deleted      = false;
            entry.deliveryRule = false;

            entry.name = (document.name.IsNull) ? null : document.name.Value.ToString();

            #region addresses
            int adressCount = document.addresses.documents.Count;
            entry.postalAddresses    = new PostalAddressFeed();
            entry.postalAddresses.Id = GetSDataId(document.Id) + "/" + SupportedResourceKinds.postalAddresses.ToString();
            for (int index = 0; index < adressCount; index++)
            {
                AddressDocument        address           = document.addresses.documents[index] as AddressDocument;
                PostalAddressFeedEntry postalAdressEntry = _postalAdressTransformation.GetTransformedPayload(address);
                if (postalAdressEntry != null)
                {
                    entry.postalAddresses.Entries.Add(postalAdressEntry);
                }
            }
            #endregion

            #region emails
            int emailsCount = document.emails.documents.Count;
            entry.emails = new EmailFeed();
            for (int index = 0; index < emailsCount; index++)
            {
                EmailDocument  email      = document.emails.documents[index] as EmailDocument;
                EmailFeedEntry emailEntry = _emailAdressTransformation.GetTransformedPayload(email);
                entry.emails.Entries.Add(emailEntry);
            }
            #endregion


            #region phones
            int phonesCount = document.phones.documents.Count;
            entry.phones = new PhoneNumberFeed();
            for (int index = 0; index < phonesCount; index++)
            {
                PhoneDocument        phone            = document.phones.documents[index] as PhoneDocument;
                PhoneNumberFeedEntry phoneNumberEntry = _phoneNumberTransformation.GetTransformedPayload(phone);
                if (phoneNumberEntry != null)
                {
                    entry.phones.Entries.Add(phoneNumberEntry);
                }
            }
            #endregion

            #region contacts
            int contactsCount = document.people.documents.Count;
            entry.contacts = new ContactFeed();
            for (int index = 0; index < contactsCount; index++)
            {
                PersonDocument   person       = document.people.documents[index] as PersonDocument;
                ContactFeedEntry contactEntry = _contactTransformation.GetTransformedPayload(person);
                if (contactEntry != null)
                {
                    entry.contacts.Entries.Add(contactEntry);
                }
            }
            #endregion

            entry.currency = _config.CurrencyCode;
            SetCommonProperties(document, entry.name, entry);
            return(entry);
        }
Exemplo n.º 25
0
 private void PrepareViewBag(PersonDocument s)
 {
 }
Exemplo n.º 26
0
        private void AttachDocument()
        {
            Person person = null;

            using (personSearchForm = new PersonSearchForm())
            {
                personSearchForm.ShowDialog();
                person = personSearchForm.SelectedPerson;
                personSearchForm.Dispose();
            }

            if (person != null)
            {
                this.Cursor = Cursors.WaitCursor;

                string userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;

                myDocType docType = (myDocType)getCheckedMenuItem(miDocumentType).Tag;

                PersonAttribute pa = new PersonAttribute(person.PersonID, docType.AttributeId);

                if (pa.IntValue == -1 ||
                    MessageBox.Show(
                        string.Format("{0} already has a {1} document associated with their record. Do you want to overwrite the existing document?", person.NickName, docType.TypeName),
                        "Document Already Exists", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes)
                {
                    Arena.Utility.ArenaDataBlob blob = new Arena.Utility.ArenaDataBlob(pa.IntValue);

                    Atalasoft.Imaging.Codec.Pdf.PdfEncoder pdf = new Atalasoft.Imaging.Codec.Pdf.PdfEncoder();
                    pdf.Metadata = new Atalasoft.Imaging.Codec.Pdf.PdfMetadata(
                        person.FullName, "", docType.DocType.TypeName,
                        "", organization.Name, "", DateTime.Now, DateTime.Now);

                    string fileName = string.Format("{0}_{1}.pdf",
                                                    person.FullName.Replace(" ", ""),
                                                    docType.TypeName.Replace(" ", ""));

                    blob.SetFileInfo(fileName);

                    using (MemoryStream ms = new MemoryStream())
                    {
                        ScannedImages.Save(ms, pdf, null);
                        blob.ByteArray = ms.ToArray();
                        ms.Close();
                    }

                    blob.Cache          = false;
                    blob.DocumentTypeID = docType.DocType.DocumentTypeId;
                    blob.Title          = docType.DocType.TypeName;

                    pa.IntValue    = blob.Save(userName);
                    pa.PersonID    = person.PersonID;
                    pa.AttributeId = docType.AttributeId;
                    pa.Save(organizationID, userName);

                    PersonDocument pDoc = new PersonDocument(person.PersonID, pa.IntValue);
                    pDoc.PersonID   = person.PersonID;
                    pDoc.DocumentID = pa.IntValue;
                    pDoc.SaveRelationship(userName);

                    ScannedImages.Clear();
                    tViewer.Items.Clear();
                    RefreshView();
                }

                this.Cursor = Cursors.Default;
            }
        }
Exemplo n.º 27
0
        public ActionResult _CreatePost(PersonDocument svm)
        {
            if (ModelState.IsValid)
            {
                if (svm.PersonDocumentID == 0)
                {
                    svm.CreatedDate  = DateTime.Now;
                    svm.ModifiedDate = DateTime.Now;
                    svm.CreatedBy    = User.Identity.Name;
                    svm.ModifiedBy   = User.Identity.Name;
                    svm.ObjectState  = Model.ObjectState.Added;
                    _PersonDocumentService.Create(svm);


                    try
                    {
                        _unitOfWork.Save();
                    }

                    catch (Exception ex)
                    {
                        string message = _exception.HandleException(ex);
                        ModelState.AddModelError("", message);
                        return(PartialView("_Create", svm));
                    }

                    LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                    {
                        DocTypeId    = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.PersonDocument).DocumentTypeId,
                        DocId        = svm.PersonDocumentID,
                        ActivityType = (int)ActivityTypeContants.Added,
                    }));


                    #region

                    //Saving Images if any uploaded after UnitOfWorkSave

                    if (Request.Files.Count > 0 && Request.Files[0].ContentLength > 0)
                    {
                        //For checking the first time if the folder exists or not-----------------------------
                        string uploadfolder;
                        int    MaxLimit;
                        int.TryParse(ConfigurationManager.AppSettings["MaxFileUploadLimit"], out MaxLimit);
                        var x = (from iid in db.Counter
                                 select iid).FirstOrDefault();
                        if (x == null)
                        {
                            uploadfolder = System.Guid.NewGuid().ToString();
                            Counter img = new Counter();
                            img.ImageFolderName = uploadfolder;
                            img.ModifiedBy      = User.Identity.Name;
                            img.CreatedBy       = User.Identity.Name;
                            img.ModifiedDate    = DateTime.Now;
                            img.CreatedDate     = DateTime.Now;
                            new CounterService(_unitOfWork).Create(img);
                            _unitOfWork.Save();
                        }

                        else
                        {
                            uploadfolder = x.ImageFolderName;
                        }


                        //For checking if the image contents length is greater than 100 then create a new folder------------------------------------

                        if (!Directory.Exists(System.Web.HttpContext.Current.Request.MapPath("~/Uploads/" + uploadfolder)))
                        {
                            Directory.CreateDirectory(System.Web.HttpContext.Current.Request.MapPath("~/Uploads/" + uploadfolder));
                        }

                        int count = Directory.GetFiles(System.Web.HttpContext.Current.Request.MapPath("~/Uploads/" + uploadfolder)).Length;

                        if (count >= MaxLimit)
                        {
                            uploadfolder = System.Guid.NewGuid().ToString();
                            var u = new CounterService(_unitOfWork).Find(x.CounterId);
                            u.ImageFolderName = uploadfolder;
                            new CounterService(_unitOfWork).Update(u);
                            _unitOfWork.Save();
                        }


                        //Saving Thumbnails images:
                        Dictionary <string, string> versions = new Dictionary <string, string>();

                        //Define the versions to generate
                        versions.Add("_thumb", "maxwidth=100&maxheight=100");  //Crop to square thumbnail
                        versions.Add("_medium", "maxwidth=200&maxheight=200"); //Fit inside 400x400 area, jpeg

                        string temp2    = "";
                        string filename = System.Guid.NewGuid().ToString();
                        foreach (string filekey in System.Web.HttpContext.Current.Request.Files.Keys)
                        {
                            HttpPostedFile pfile = System.Web.HttpContext.Current.Request.Files[filekey];
                            if (pfile.ContentLength <= 0)
                            {
                                continue;                           //Skip unused file controls.
                            }
                            temp2 = Path.GetExtension(pfile.FileName);

                            string uploadFolder = System.Web.HttpContext.Current.Request.MapPath("~/Uploads/" + uploadfolder);
                            if (!Directory.Exists(uploadFolder))
                            {
                                Directory.CreateDirectory(uploadFolder);
                            }

                            string filecontent = Path.Combine(uploadFolder, svm.Name + "_" + filename);

                            //pfile.SaveAs(filecontent);
                            ImageBuilder.Current.Build(new ImageJob(pfile, filecontent, new Instructions(), false, true));


                            //Generate each version
                            foreach (string suffix in versions.Keys)
                            {
                                if (suffix == "_thumb")
                                {
                                    string tuploadFolder = System.Web.HttpContext.Current.Request.MapPath("~/Uploads/" + uploadfolder + "/Thumbs");
                                    if (!Directory.Exists(tuploadFolder))
                                    {
                                        Directory.CreateDirectory(tuploadFolder);
                                    }

                                    //Generate a filename (GUIDs are best).
                                    string tfileName = Path.Combine(tuploadFolder, svm.Name + "_" + filename);

                                    //Let the image builder add the correct extension based on the output file type
                                    //fileName = ImageBuilder.Current.Build(file, fileName, new ResizeSettings(versions[suffix]), false, true);
                                    ImageBuilder.Current.Build(new ImageJob(pfile, tfileName, new Instructions(versions[suffix]), false, true));
                                }
                                else if (suffix == "_medium")
                                {
                                    string tuploadFolder = System.Web.HttpContext.Current.Request.MapPath("~/Uploads/" + uploadfolder + "/Medium");
                                    if (!Directory.Exists(tuploadFolder))
                                    {
                                        Directory.CreateDirectory(tuploadFolder);
                                    }

                                    //Generate a filename (GUIDs are best).
                                    string tfileName = Path.Combine(tuploadFolder, svm.Name + "_" + filename);

                                    //Let the image builder add the correct extension based on the output file type
                                    //fileName = ImageBuilder.Current.Build(file, fileName, new ResizeSettings(versions[suffix]), false, true);
                                    ImageBuilder.Current.Build(new ImageJob(pfile, tfileName, new Instructions(versions[suffix]), false, true));
                                }
                            }

                            //var tempsave = _FinishedProductService.Find(pt.ProductId);

                            svm.ImageFileName   = svm.Name + "_" + filename + temp2;
                            svm.ImageFolderName = uploadfolder;
                            svm.ObjectState     = Model.ObjectState.Modified;
                            _PersonDocumentService.Update(svm);
                            _unitOfWork.Save();
                        }
                    }

                    #endregion



                    return(RedirectToAction("_Create", new { id = svm.PersonId }));
                }
                else
                {
                    svm.ModifiedBy   = User.Identity.Name;
                    svm.ModifiedDate = DateTime.Now;
                    _PersonDocumentService.Update(svm);

                    try
                    {
                        _unitOfWork.Save();
                    }

                    catch (Exception ex)
                    {
                        string message = _exception.HandleException(ex);
                        ModelState.AddModelError("", message);
                        return(PartialView("_Create", svm));
                    }

                    LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                    {
                        DocTypeId    = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.PersonDocument).DocumentTypeId,
                        DocId        = svm.PersonDocumentID,
                        ActivityType = (int)ActivityTypeContants.Modified,
                    }));

                    #region

                    //Saving Image if file is uploaded
                    if (Request.Files.Count > 0 && Request.Files[0].ContentLength > 0)
                    {
                        string uploadfolder = svm.ImageFolderName;
                        string tempfilename = svm.ImageFileName;
                        if (uploadfolder == null)
                        {
                            var x = (from iid in db.Counter
                                     select iid).FirstOrDefault();
                            if (x == null)
                            {
                                uploadfolder = System.Guid.NewGuid().ToString();
                                Counter img = new Counter();
                                img.ImageFolderName = uploadfolder;
                                img.ModifiedBy      = User.Identity.Name;
                                img.CreatedBy       = User.Identity.Name;
                                img.ModifiedDate    = DateTime.Now;
                                img.CreatedDate     = DateTime.Now;
                                new CounterService(_unitOfWork).Create(img);
                                _unitOfWork.Save();
                            }
                            else
                            {
                                uploadfolder = x.ImageFolderName;
                            }
                        }
                        //Deleting Existing Images

                        var xtemp = System.Web.HttpContext.Current.Server.MapPath("~/Uploads/" + uploadfolder + "/" + tempfilename);
                        if (System.IO.File.Exists(System.Web.HttpContext.Current.Server.MapPath("~/Uploads/" + uploadfolder + "/" + tempfilename)))
                        {
                            System.IO.File.Delete(System.Web.HttpContext.Current.Server.MapPath("~/Uploads/" + uploadfolder + "/" + tempfilename));
                        }

                        //Deleting Thumbnail Image:

                        if (System.IO.File.Exists(System.Web.HttpContext.Current.Server.MapPath("~/Uploads/" + uploadfolder + "/Thumbs/" + tempfilename)))
                        {
                            System.IO.File.Delete(System.Web.HttpContext.Current.Server.MapPath("~/Uploads/" + uploadfolder + "/Thumbs/" + tempfilename));
                        }

                        //Deleting Medium Image:
                        if (System.IO.File.Exists(System.Web.HttpContext.Current.Server.MapPath("~/Uploads/" + uploadfolder + "/Medium/" + tempfilename)))
                        {
                            System.IO.File.Delete(System.Web.HttpContext.Current.Server.MapPath("~/Uploads/" + uploadfolder + "/Medium/" + tempfilename));
                        }

                        //Saving Thumbnails images:
                        Dictionary <string, string> versions = new Dictionary <string, string>();

                        //Define the versions to generate
                        versions.Add("_thumb", "maxwidth=100&maxheight=100");  //Crop to square thumbnail
                        versions.Add("_medium", "maxwidth=200&maxheight=200"); //Fit inside 400x400 area, jpeg

                        string temp2    = "";
                        string filename = System.Guid.NewGuid().ToString();
                        foreach (string filekey in System.Web.HttpContext.Current.Request.Files.Keys)
                        {
                            HttpPostedFile pfile = System.Web.HttpContext.Current.Request.Files[filekey];
                            if (pfile.ContentLength <= 0)
                            {
                                continue;                           //Skip unused file controls.
                            }
                            temp2 = Path.GetExtension(pfile.FileName);

                            string uploadFolder = System.Web.HttpContext.Current.Request.MapPath("~/Uploads/" + uploadfolder);
                            if (!Directory.Exists(uploadFolder))
                            {
                                Directory.CreateDirectory(uploadFolder);
                            }

                            string filecontent = Path.Combine(uploadFolder, svm.Name + "_" + filename);

                            //pfile.SaveAs(filecontent);

                            ImageBuilder.Current.Build(new ImageJob(pfile, filecontent, new Instructions(), false, true));

                            //Generate each version
                            foreach (string suffix in versions.Keys)
                            {
                                if (suffix == "_thumb")
                                {
                                    string tuploadFolder = System.Web.HttpContext.Current.Request.MapPath("~/Uploads/" + uploadfolder + "/Thumbs");
                                    if (!Directory.Exists(tuploadFolder))
                                    {
                                        Directory.CreateDirectory(tuploadFolder);
                                    }

                                    //Generate a filename (GUIDs are best).
                                    string tfileName = Path.Combine(tuploadFolder, svm.Name + "_" + filename);

                                    //Let the image builder add the correct extension based on the output file type
                                    //fileName = ImageBuilder.Current.Build(file, fileName, new ResizeSettings(versions[suffix]), false, true);
                                    ImageBuilder.Current.Build(new ImageJob(pfile, tfileName, new Instructions(versions[suffix]), false, true));
                                }
                                else if (suffix == "_medium")
                                {
                                    string tuploadFolder = System.Web.HttpContext.Current.Request.MapPath("~/Uploads/" + uploadfolder + "/Medium");
                                    if (!Directory.Exists(tuploadFolder))
                                    {
                                        Directory.CreateDirectory(tuploadFolder);
                                    }

                                    //Generate a filename (GUIDs are best).
                                    string tfileName = Path.Combine(tuploadFolder, svm.Name + "_" + filename);

                                    //Let the image builder add the correct extension based on the output file type
                                    //fileName = ImageBuilder.Current.Build(file, fileName, new ResizeSettings(versions[suffix]), false, true);
                                    ImageBuilder.Current.Build(new ImageJob(pfile, tfileName, new Instructions(versions[suffix]), false, true));
                                }
                            }
                        }
                        var temsave = _PersonDocumentService.Find(svm.PersonDocumentID);
                        temsave.ImageFileName   = temsave.Name + "_" + filename + temp2;
                        temsave.ImageFolderName = uploadfolder;
                        _PersonDocumentService.Update(temsave);
                        _unitOfWork.Save();
                    }

                    #endregion

                    return(Json(new { success = true }));
                }
            }

            PrepareViewBag(svm);
            return(PartialView("_Create", svm));
        }
Exemplo n.º 28
0
        public PageOfPersonDocuments SearchPersons(int pageNumber, int numRecordsInPage, string sort, SortDirection sortDirection, PersonDocument searchCriteria)
        {
            var pageOfListPerson = footlooseService.SearchPersonDocuments(pageNumber, numRecordsInPage, sort, sortDirection, searchCriteria);

            var pageOfPersons = new PageOfPersonDocuments();

            pageOfPersons.Data           = pageOfListPerson.Data;
            pageOfPersons.PageIndex      = pageOfListPerson.PageIndex;
            pageOfPersons.PageSize       = pageOfListPerson.PageSize;
            pageOfPersons.TotalItemCount = pageOfListPerson.TotalItemCount;

            return(pageOfPersons);
        }
        public ActionResult Search(SearchParameters searchParameters)
        {
            // Serialize sort direction to an enum of SortDirection
            SortDirection sortDirection = SortDirection.Ascending;

            Enum.TryParse <SortDirection>(searchParameters.SortDirection, out sortDirection);

            var searchCriteria = new PersonDocument();

            if (searchParameters.SearchCriteria != null && searchParameters.SearchCriteria.Count() > 0)
            {
                foreach (var searchCriterion in searchParameters.SearchCriteria)
                {
                    if (!string.IsNullOrEmpty(searchCriterion.Value))
                    {
                        if (searchCriterion.Key == "PersonID")
                        {
                            searchCriteria.PersonID = Int32.Parse(searchCriterion.Value);
                        }
                        else if (searchCriterion.Key == "FirstName")
                        {
                            searchCriteria.FirstName = searchCriterion.Value;
                        }
                        else if (searchCriterion.Key == "LastName")
                        {
                            searchCriteria.LastName = searchCriterion.Value;
                        }
                        else if (searchCriterion.Key == "PhoneNumber")
                        {
                            searchCriteria.PhoneNumber = searchCriterion.Value;
                        }
                        else if (searchCriterion.Key == "StreetAddress")
                        {
                            searchCriteria.StreetAddress = searchCriterion.Value;
                        }
                        else if (searchCriterion.Key == "City")
                        {
                            searchCriteria.City = searchCriterion.Value;
                        }
                        else if (searchCriterion.Key == "Zip")
                        {
                            searchCriteria.Zip = searchCriterion.Value;
                        }
                        else if (searchCriterion.Key == "State")
                        {
                            searchCriteria.State = searchCriterion.Value;
                        }
                        else if (searchCriterion.Key == "EmailAddress")
                        {
                            searchCriteria.EmailAddress = searchCriterion.Value;
                        }
                    }
                }
            }

            var personsPage = personService.SearchPersons(searchParameters.PageNumber, searchParameters.NumberRecordsPerPage, searchParameters.SortColumn, sortDirection, searchCriteria);

            var pageOfListPersonDocuments = new PageOfList <PersonDocument>(personsPage.Data, searchParameters.PageNumber, searchParameters.NumberRecordsPerPage, personsPage.TotalItemCount);

            pageOfListPersonDocuments.SearchCriteria = searchParameters.SearchCriteria;

            return(PartialView(pageOfListPersonDocuments));
        }
Exemplo n.º 30
0
 public PersonDocument Create(PersonDocument pt)
 {
     pt.ObjectState = ObjectState.Added;
     _unitOfWork.Repository <PersonDocument>().Insert(pt);
     return(pt);
 }
Exemplo n.º 31
0
 public void Delete(PersonDocument pt)
 {
     _unitOfWork.Repository <PersonDocument>().Delete(pt);
 }
Exemplo n.º 32
0
        public PageOfList <PersonDocument> SearchPersonDocuments(int pageNumber, int numRecordsInPage, string sort, SortDirection sortDirection, PersonDocument searchCriteria)
        {
            // Note the Document Unit of Work will be disposed when out of scope (does not require using statement)
            var unitOfWork = new FootlooseFSDocUnitOfWork();

            // Search, sort, and page the results
            return(unitOfWork.Persons.Search(pageNumber, numRecordsInPage, searchCriteria, sort, sortDirection));
        }