Ejemplo n.º 1
0
        public static void Fill(Models.Person entity, ViewModels.ViewPersonDto viewperson)
        {
            entity.Id         = viewperson.Id;
            entity.DateCreate = viewperson.DateCreate;
            entity.SexId      = viewperson.SexId;
            entity.FirstName  = viewperson.FirstName;
            entity.LastName   = viewperson.LastName;
            entity.DateBirth  = viewperson.DateBirth;
            entity.Email      = viewperson.Email;
            entity.Mobile     = viewperson.Mobile;
            entity.Address    = viewperson.Address;
            entity.IsActive   = viewperson.IsActive;
            entity.IsDeleted  = viewperson.IsDeleted;
            entity.Remark     = viewperson.Remark;
            entity.Nickname   = viewperson.Nickname;
            entity.IDNo       = viewperson.IDNo;
            entity.UserId     = viewperson.UserId;
            entity.ImageUrl   = viewperson.ImageUrl;
            entity.CountryId  = viewperson.CountryId;
            entity.ZIPCode    = viewperson.ZIPCode;
            entity.State      = viewperson.State;
            entity.City       = viewperson.City;
            entity.Company    = viewperson.Company;
            entity.University = viewperson.University;
            entity.Website    = viewperson.Website;
            entity.Twitter    = viewperson.Twitter;
            entity.LinkedIn   = viewperson.LinkedIn;
            entity.Headline   = viewperson.Headline;
            entity.DegreeId   = viewperson.DegreeId;
            entity.PositionId = viewperson.PositionId;
            entity.DateJoin   = viewperson.DateJoin;

            entity.FieldOfStudyId = viewperson.FieldOfStudyId;
        }
Ejemplo n.º 2
0
        public InvoiceGridSpec(Models.Person currentPerson, bool invoiceFileExistsOnAtLeastOne)
        {
            ObjectNameSingular  = $"{Models.FieldDefinition.Invoice.GetFieldDefinitionLabel()}";
            ObjectNamePlural    = $"{Models.FieldDefinition.Invoice.GetFieldDefinitionLabelPluralized()}";
            SaveFiltersInCookie = true;
            var userHasCreatePermissions = new InvoiceCreateFeature().HasPermissionByPerson(currentPerson);

            if (userHasCreatePermissions)
            {
                var contentUrl = SitkaRoute <InvoiceController> .BuildUrlFromExpression(t => t.New());

                CreateEntityModalDialogForm = new ModalDialogForm(contentUrl, "Create a new Invoice");
            }

            if (invoiceFileExistsOnAtLeastOne)
            {
                Add(string.Empty, x => DhtmlxGridHtmlHelpers.MakeFileDownloadIconAsHyperlinkBootstrap(x.GetFileDownloadUrl(), "Download Invoice file"), 30, DhtmlxGridColumnFilterType.None);
            }

            Add("Invoice ID", x => UrlTemplate.MakeHrefString(x.GetDetailUrl(), x.InvoiceID.ToString()), 50);
            Add(Models.FieldDefinition.InvoiceIdentifyingName.ToGridHeaderString(), x => UrlTemplate.MakeHrefString(x.GetDetailUrl(), x.InvoiceIdentifyingName),
                InvoiceGridSpec.InvoiceColumnWidth, DhtmlxGridColumnFilterType.SelectFilterHtmlStrict);
            Add(Models.FieldDefinition.RequestorName.ToGridHeaderString(), x => x.RequestorName, InvoiceGridSpec.InvoiceColumnWidth, DhtmlxGridColumnFilterType.SelectFilterStrict);
            Add(Models.FieldDefinition.InvoiceDate.ToGridHeaderString(), x => x.InvoiceDate, 90, DhtmlxGridColumnFormatType.Date);
            Add(Models.FieldDefinition.PurchaseAuthority.ToGridHeaderString(), x => x.PurchaseAuthorityDisplay, InvoiceGridSpec.InvoiceColumnWidth, DhtmlxGridColumnFilterType.SelectFilterStrict);
            Add(Models.FieldDefinition.InvoiceStatus.ToGridHeaderString(), x =>
                x.InvoiceStatus.InvoiceStatusDisplayName, InvoiceGridSpec.InvoiceColumnWidth, DhtmlxGridColumnFilterType.SelectFilterStrict);
            Add(Models.FieldDefinition.TotalRequestedInvoicePaymentAmount.ToGridHeaderString(), x => x.TotalPaymentAmount.ToStringCurrency(), 90, DhtmlxGridColumnFilterType.SelectFilterStrict);
            Add(Models.FieldDefinition.InvoiceApprovalStatus.ToGridHeaderString(), x =>
                x.InvoiceApprovalStatus.InvoiceApprovalStatusName, InvoiceGridSpec.InvoiceColumnWidth, DhtmlxGridColumnFilterType.SelectFilterStrict);
            Add(Models.FieldDefinition.PreparedByPerson.ToGridHeaderString(), x => x.PreparedByPerson.FullNameFirstLast, 90, DhtmlxGridColumnFilterType.SelectFilterStrict);
        }
Ejemplo n.º 3
0
        private void LoadElements()
        {
            using (Models.OrganizerDB context = new Models.OrganizerDB())
            {
                Models.Person pers = context.Person.Find(Classes.SelectContact.SelectContactID);

                var brush = new ImageBrush();
                brush.ImageSource      = ImageFunc.ConvertImageFromBinary(pers.PersonPhoto);
                PersonPhoto.Background = brush;

                Name.Text       = pers.Name;
                LastName.Text   = pers.Lastname;
                Patronymic.Text = pers.Patronymic;

                if (pers.Gender == "М")
                {
                    Gender.SelectedIndex = 0;
                }
                else
                {
                    Gender.SelectedIndex = 1;
                }

                DOB.Text         = pers.DOB;
                NickName.Text    = pers.NickName;
                PhoneNumber.Text = pers.Phone_number;
                Position.Text    = pers.Position;
                Email.Text       = pers.Email;
                Adress.Text      = pers.AdressPerson;
            }
        }
Ejemplo n.º 4
0
        //gets the courses that the user has
        public Models.Person GetUserInfo(string UNI)
        {
            Models.Person person = new Models.Person();
            SqlOpenConnection();
            string     sqlUse      = "USE ProjectStyring;";
            SqlCommand sqlUseQuery = new SqlCommand(sqlUse, connection);

            try
            {
                string     query    = string.Format("exec dbo.spCourse_GetUsersCourse '{0}'", UNI);
                SqlCommand sqlQuery = new SqlCommand(query, connection);
                sqlUseQuery.ExecuteNonQuery();
                using (SqlDataReader reader = sqlQuery.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        try
                        {
                            person.Courses.Add(new Models.Course(reader.GetInt32(0), reader.GetInt32(1), reader.GetDateTime(2), reader.GetDateTime(3)));
                        }
                        catch { }
                    }
                }
                connection.Close();
                return(person);
            }
            catch
            {
                connection.Close();
                return(person);
            }
        }
 public void RemovePersonToUserGroup(Models.Person p, Models.UserGroup ug)
 {
     if (ug.PersonInGroup.Contains(p))
     {
         ug.PersonInGroup.Add(p);
     }
 }
Ejemplo n.º 6
0
        public void CheckDate(DateTime date)
        {
            var           age    = DateTime.Today.Date.Year - date.Date.Year;
            OperateZodiac zodiac = new OperateZodiac();

            if (zodiac.isBirthday(date.Date))
            {
                MessageBox.Show("Вітаємо з днем народження!");
            }
            try
            {
                Person TestPerson = new Models.Person();
                TestPerson.IsCorrectDateOfBirth(date);
                if (TestPerson.IsEmailValid(_email))
                {
                    MessageBox.Show("Email правильний");
                }
                else
                {
                    throw new IllegalEmailException();
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
            Person _mainPerson = new Person(_email, _name, _surname, date);

            _loginModel._storage.ChangeInfo(_mainPerson);
        }
Ejemplo n.º 7
0
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here
                Models.Person thePerson = database.People.SingleOrDefault(c => c.person_id == id);

                thePerson.picture_id = null;
                database.SaveChanges();

                database.Pictures.RemoveRange(thePerson.Pictures);
                database.Contacts.RemoveRange(thePerson.Contacts);
                database.Addresses.RemoveRange(thePerson.Addresses);
                database.SaveChanges();

                database.People.Remove(thePerson);
                database.SaveChanges();

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Ejemplo n.º 8
0
        public AddContactViewModel(MainWindowViewModel parentVM, Person person)
        {
            try
            {
                AddPerson = person;

                object dc             = Application.Current.MainWindow.DataContext;
                MainWindowViewModel t = (MainWindowViewModel)dc;
                HeaderTitle = t.GetDescriptions.EditContact_title;

                ParentVM = parentVM;
                LoadCommands();

                CountryList.Add(new County()
                {
                    Name = "Italy", CountryCode = "ITA", Number = "+39"
                });
                CountryList.Add(new County()
                {
                    Name = "China", CountryCode = "CHN", Number = "+22"
                });
                CountryList.Add(new County()
                {
                    Name = "UK", CountryCode = "ENG", Number = "+12"
                });

                CountySelected = CountryList[0];
                NotifyPropertyChanged("CountySelected");
                NotifyPropertyChanged("CountryList");
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
            }
        }
Ejemplo n.º 9
0
        public IHttpActionResult Put(int id, Models.Person personDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }


            Handin22.Person person = _unitOfWork.Persons.Get(id);

            if (person == null)
            {
                return(NotFound());
            }

            person.FirstName  = personDto.FirstName;
            person.MiddleName = personDto.MiddleName;
            person.LastName   = personDto.LastName;
            person.PersonId   = personDto.PersonId;
            person.Type       = personDto.Type;

            _unitOfWork.Complete();

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 10
0
        public IHttpActionResult Post(int id, Models.Person personDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }


            if (_unitOfWork.Persons.Get(id) != null)
            {
                return(StatusCode(HttpStatusCode.NotAcceptable));
            }


            Handin22.Person person = new Handin22.Person(personDto.FirstName, personDto.LastName, personDto.Type)
            {
                MiddleName = personDto.MiddleName,
                LastName   = personDto.LastName,
                PersonId   = personDto.PersonId,
                Type       = personDto.Type
            };

            person.AAdresses.Add(_unitOfWork.Adress.Get(Int32.Parse(personDto.AdressId)));

            _unitOfWork.Persons.Add(person);
            _unitOfWork.Complete();

            return(StatusCode(HttpStatusCode.Accepted));
        }
Ejemplo n.º 11
0
        public Models.Person Make()
        {
            var person = new Models.Person()
            {
                Birthday = Faker.Date.Birthday(),
                EMail    = Faker.User.Email(),
                Id       = 0,
                NameLast = Faker.Name.LastName()
            };

            var gender = Faker.Name.Gender();

            if (gender.ToLowerInvariant().StartsWith("f"))
            {
                person.NameFirst = Faker.Name.FemaleFirstName();
            }
            else
            {
                person.NameFirst = Faker.Name.MaleFirstName();
            }

            person.Company = person.EMail.Substring(person.EMail.IndexOf('@') + 1);

            person.EMail = string.Format("{0}.{1}@{2}", person.NameFirst, person.NameLast, person.Company);

            return(person);
        }
Ejemplo n.º 12
0
        public void WritePerson()
        {
            Task task = new Task(async() =>
            {
                var personToWrite = new Models.Person()
                {
                    Name = "Test"
                };
                IDataWriter dataWriter = new DataWriter(Configuration)
                {
                    ConnectionStringName = ConnectionStringName
                };
                await dataWriter.WritePerson(personToWrite);

                IDataReader reader = new DataReader(Configuration)
                {
                    ConnectionStringName = ConnectionStringName
                };
                var people = await reader.GetPeople();
                if (!people.Contains(personToWrite))
                {
                    throw new Exception("Person failed to write to database");
                }
            });

            task.RunSynchronously();
        }
Ejemplo n.º 13
0
 public Models.Person Build()
 {
     Models.Person person = new Models.Person();
     person.Name    = this.FirstName;
     person.Surname = this.LastName;
     return(person);
 }
Ejemplo n.º 14
0
 public PersonViewModel()
 {
     Person = new Models.Person()
     {
         FirstName = "Paw", Surnames = "Hauge Byrialsen", Age = 45, IsChecked = false
     };
 }
 public void AddUser(Models.Person p)
 {
     if (!_store.People.Exists(o => o.DNVGLID == p.DNVGLID))
     {
         _store.People.Add(p);
     }
 }
 public PersonDetailPageViewModel()
 {
     EditPerson = new Models.Person()
     {
         Id = Utilities.MockData.People[Utilities.MockData.People.Count - 1].Id + 1,
     };
 }
Ejemplo n.º 17
0
        protected override void Seed(Data.StoreDbContext context)
        {
            var modelPerson = new Models.Person()
            {
                Id        = 2,
                FirstName = "Ivan",
                LastName  = "Ivanov",
                Email     = "[email protected] ",
                Password  = "******"
            };

            context.Customers.AddOrUpdate(x => x.Id,
                                          new Models.Customer()
            {
                Person = modelPerson
            }
                                          );

            context.Departments.AddOrUpdate(x => x.Id, new Models.Department()
            {
                Id   = 2,
                Name = "Ivan Ivanov"
            });

            context.Employees.AddOrUpdate(x => x.Id,
                                          new Models.Employee()
            {
                Id             = 2,
                EmployeeNumber = "123",
                PhoneNumber    = "0899606063",
                PersonId       = 2,
                DepartmentId   = 2
            });
        }
Ejemplo n.º 18
0
        public ActionResult ColorNameResult()
        {
            Person        person = new Models.Person();
            List <string> colors = new List <string>();

            if (Request.Params["First"] != null && Request.Params["Last"] != null)
            {
                person.FirstName = Request.Params["First"];
                person.LastName  = Request.Params["Last"];
            }

            if (Request["Red"] != null && Request["Red"].Contains("true"))
            {
                colors.Add("red");
            }
            if (Request["Blue"] != null && Request["Blue"].Contains("true"))
            {
                colors.Add("blue");
            }
            if (Request["Green"] != null && Request["Green"].Contains("true"))
            {
                colors.Add("green");
            }

            person.ColorsForName = colors;

            return(View(person));
        }
Ejemplo n.º 19
0
        public GisRecordGridSpec(Models.Person currentPerson, List <GisUploadAttemptGisMetadataAttribute> columns, List <Models.GisFeature> gisFeatures, GisUploadAttempt gisUploadAttempt)
        {
            ObjectNameSingular  = $"GIS Record";
            ObjectNamePlural    = $"GIS Records";
            SaveFiltersInCookie = false;
            var gisFeatureIDs = gisFeatures.Select(x => x.GisFeatureID);
            var allAttributesOnGisUploadAttempt = HttpRequestStorage.DatabaseEntities.GisFeatureMetadataAttributes.Where(x => gisFeatureIDs.Contains(x.GisFeatureID)).ToList();
            var dictionary     = allAttributesOnGisUploadAttempt.GroupBy(x => x.GisMetadataAttributeID).ToDictionary(x => x.Key, y => y.ToList());
            var columnsOrdered = columns
                                 .Where(x => !string.Equals(x.GisMetadataAttribute.GisMetadataAttributeName, "Shape", StringComparison.InvariantCultureIgnoreCase))
                                 .Where(x => dictionary.ContainsKey(x.GisMetadataAttributeID))
                                 .OrderBy(x => x.SortOrder)
                                 .ToList();


            Add("ID", x => UrlTemplate.MakeHrefString(x.GetDetailUrl(), x.GisFeatureID.ToString()), 90, DhtmlxGridColumnFilterType.SelectFilterHtmlStrict);
            Add("Is Valid", x => (x.IsValid ?? false).ToString(), 90, DhtmlxGridColumnFilterType.SelectFilterStrict);
            Add("Calculated Area in Acres", x => x.CalculatedArea.ToString(), 90, DhtmlxGridColumnFilterType.Numeric);

            foreach (var fGetColumnNamesForTableResult in columnsOrdered)
            {
                Add(fGetColumnNamesForTableResult.GisMetadataAttribute.GisMetadataAttributeName
                    , x => x.GisFeatureMetadataAttributes.SingleOrDefault(y => y.GisMetadataAttributeID == fGetColumnNamesForTableResult.GisMetadataAttributeID)?.GisFeatureMetadataAttributeValue, 90, DhtmlxGridColumnFilterType.Text);
            }
        }
Ejemplo n.º 20
0
        public string findPerson(int id)
        {
            List <Models.Person> items = new List <Models.Person>();

            string[] Names = { "jan", "Jan", "jan", "aaron", "abdul", "abe", "abel", "abraham", "adam", "adan", "adolfo", "adolph", "adrian", "abby", "abigail", "adele", "adrian" };
            foreach (string nameList in Names)
            {
                Models.Person person = new Models.Person(nameList, nameList + "@hotmail.com");
                items.Add(person);
            }


            string message = "";

            if (id <= items.Count)
            {
                Models.Person person = items.ElementAt(id);
                message = string.Format("Email = {0}", person.email);
            }
            else
            {
                message = string.Format("User with id of {0} not found", id);
            }


            return(message);
        }
Ejemplo n.º 21
0
        public ActionResult OrderResult()
        {
            Person person = new Models.Person();

            if (Request.Params["First"] != null && Request.Params["Middle"] != null && Request.Params["Last"] != null)
            {
                person.FirstName = Request.Params["First"];
                person.Middle    = Request.Params["Middle"];
                person.LastName  = Request.Params["Last"];
            }


            if (Request["Order"] != null)
            {
                string orderType = Request["Order"];
                if (orderType == "FML")
                {
                    person.OrderedName = person.FirstName + " " + person.Middle + " " + person.LastName;
                }
                else if (orderType == "FL")
                {
                    person.OrderedName = person.FirstName + " " + person.LastName;
                }
                else if (orderType == "LFM")
                {
                    person.OrderedName = person.LastName + ", " + person.FirstName + " " + person.Middle;
                }
                else if (orderType == "LF")
                {
                    person.OrderedName = person.LastName + ", " + person.FirstName;
                }
            }

            return(View(person));
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Select in line script
        /// </summary>
        /// <returns></returns>
        public List <Models.Person> GetPersons()
        {
            List <Models.Person> matchingPerson = new List <Models.Person>();

            using (SqlConnection myConnection = CreateConnection())
            {
                string     oString = "Select * from [AdventureWorks2014].[Person].[Person]";
                SqlCommand oCmd    = new SqlCommand(oString, myConnection);
                myConnection.Open();
                using (SqlDataReader oReader = oCmd.ExecuteReader())
                {
                    while (oReader.Read())
                    {
                        Models.Person person = new Models.Person();
                        person.FirstName  = oReader["FirstName"].ToString();
                        person.MiddleName = oReader["MiddleName"].ToString();
                        person.LastName   = oReader["LastName"].ToString();

                        matchingPerson.Add(person);
                    }

                    myConnection.Close();
                }
            }

            return(matchingPerson);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Stored procedure
        /// </summary>
        /// <returns></returns>
        public List <Models.Person> GetPersonsSP()
        {
            List <Models.Person> matchingPerson = new List <Models.Person>();

            using (SqlConnection myConnection = CreateConnection())
            {
                SqlCommand oCmd = new SqlCommand("GetPersons", myConnection);
                oCmd.CommandType = CommandType.StoredProcedure;

                myConnection.Open();
                using (SqlDataReader oReader = oCmd.ExecuteReader())
                {
                    while (oReader.Read())
                    {
                        Models.Person person = new Models.Person();
                        person.FirstName  = oReader["FirstName"].ToString();
                        person.MiddleName = oReader["MiddleName"].ToString();
                        person.LastName   = oReader["LastName"].ToString();

                        matchingPerson.Add(person);
                    }

                    myConnection.Close();
                }
            }

            return(matchingPerson);
        }
Ejemplo n.º 24
0
        public List <Models.Group> GetGroupListFull(Dal.AD ad, Dal.SQL sql)
        {
            List <Models.Group> groups = sql.GetGroupList(false);

            for (int i = 0; i < groups.Count; i++)
            {
                groups[i].Members = sql.GetMemberList(groups[i].Id);
                for (int j = 0; j < groups[i].Members.Count; j++)
                {
                    Models.Person person       = new Models.Person();
                    Models.Course personCourse = sql.GetPersonsCourse(groups[i].Members[j].UNI);
                    if (personCourse.StartCourse < DateTime.Now && personCourse.EndCourse > DateTime.Now)
                    {
                        person.OnCourse = true;
                    }
                    else
                    {
                        person.OnCourse = false;
                    }
                    person.Name          = ad.GetUserInfo(groups[i].Members[j].UNI).Name;
                    groups[i].Members[j] = person;
                }
            }
            return(groups);
        }
Ejemplo n.º 25
0
        //makes a group object with all
        public Models.Group GetSingleGroup(int id, Dal.AD ad, Dal.SQL sql)
        {
            List <Models.Person> members      = new List <Models.Person>();
            List <Models.Person> membersSmall = new List <Models.Person>();
            List <Models.Task>   tasks        = new List <Models.Task>();

            //makes the list of members
            membersSmall = sql.GetMemberList(id);
            foreach (Models.Person p in membersSmall)
            {
                Models.Person person = ad.GetUserInfo(p.UNI);
                members.Add(new Models.Person(person.Name, p.UNI, person.Studing, p.Admin));
            }

            //makes the list of tasks
            tasks = sql.GetTaskList(id, DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd HH:mm:ss"));

            //gets the base info about the group
            Models.Group group = sql.GetbasicInfoAboutGroup(id);

            //gets all the comments for that group
            List <Models.Comment> comments = sql.GetCommentList(id);

            for (int i = 0; i < comments.Count; i++)
            {
                comments[i] = new Models.Comment(comments[i].ID, ad.GetUserInfo(comments[i].Name).Name, comments[i].Datetime, comments[i].CommentText, true);
            }

            return(new Models.Group(group.Name, group.Id, group.Description, group.Complete, group.StartDate, members, tasks, comments, group.EndDate));
        }
Ejemplo n.º 26
0
        public DetailedInformationWindowViewModel(Models.Kontakt param)
        {
            Color = Brushes.LightGreen;
            RaisePropertyChanged("Color");

            Firmen = new List <Models.Firma>();
            GetFirmen();
            amountFirmen = 0;

            //ParamFirma = new Models.Firma();
            //ParamPerson = new Models.Person();

            Firma  = new Models.Firma();
            Person = new Models.Person();

            if (param is Models.Firma)
            {
                //ParamFirma = (Models.Firma)param;
                Firma = (Models.Firma)param.Clone();
            }
            else
            {
                //ParamPerson = (Models.Person)param;
                Person   = (Models.Person)param.Clone();
                isPerson = true;
            }
        }
Ejemplo n.º 27
0
 public IUser CreateUser(string name1, string name2)
 {
     Models.Person person = new Models.Person();
     person.Name    = name1;
     person.Surname = name2;
     return(person);
 }
        // GET: Picture
        public ActionResult Index(int id) // person_id -> Session["user_id"]
        {
            int id = int.Parse(Session["user_id"].ToString());

            Models.Person person = db.People.SingleOrDefault(p => p.person_id == id);
            return(View(person)); // list of pictures
        }
        // GET: Address
        public ActionResult Index(int id)//Person ID
        {
            ViewBag.id = id;

            Models.Person thePerson = database.People.SingleOrDefault(c => c.person_id == id);
            return(View(thePerson));
        }
Ejemplo n.º 30
0
        public async Task <IActionResult> Put(Guid id, Models.Person person)
        {
            Models.Person returnPerson;
            try
            {
                var dbPerson = _context.Persons.Where(per => per.PersonId.Equals(id)).SingleOrDefault();
                dbPerson.DateOfBirth = person.DateOfBirth;
                dbPerson.GivenName1  = person.GivenName1;
                dbPerson.GivenName2  = person.GivenName2;
                dbPerson.GivenName3  = person.GivenName3;
                dbPerson.FamilyName  = person.FamilyName;
                dbPerson.Alerts      = person.Alerts;

                //Set the retrun object
                returnPerson = dbPerson;
            }
            catch {
                // _context.Entry(person).State = EntityState.Modified;
                _context.Persons.Add(person);

                //Set the retrun object
                returnPerson = person;
            };

            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(Get), new { id = person.PersonId }, person));
        }
        public ActionResult Advanced()
        {
            var person = new Models.Person
            {
                FirstName = "Eric",
                LastName = "McQuiggan"
            };

            return View(person);
        }
Ejemplo n.º 32
0
 public ActionResult Captura(Int32 IdPersona)
 {
     TestPerson.Models.Person PersonEdit = null;
     if(IdPersona != 0)
     {
         TestEntities context = new TestEntities();
         var person = from r in context.Personas
                      where r.Id == IdPersona
                      select r;
         foreach (Personas p in person)
         {
             PersonEdit = new Models.Person { Id = p.Id, Nombre = p.Nombre, FechaNac = p.FechaNacimiento.ToShortDateString(), Pic = p.Foto };
         }
         return View(PersonEdit);
     }
     return View();
 }
Ejemplo n.º 33
0
 public ActionResult Index()
 {
     List<TestPerson.Models.Person> ListaPersonas = new List<Models.Person>();
     using (TestEntities context = new TestEntities())
     {
         var person = (from r in context.Personas select r);
         foreach (Personas record in person)
         {
             Models.Person p = new Models.Person { Id= record.Id, Nombre = record.Nombre, FechaNac = record.FechaNacimiento.ToShortDateString(), Pic = (Byte[]) record.Foto };
             ListaPersonas.Add(p);
         }
     }
     return View("Index", ListaPersonas);
 }
Ejemplo n.º 34
0
        public async Task<ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser { UserName = model.Email, Email = model.Email };
                var result = await UserManager.CreateAsync(user, model.Password);
                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, isPersistent:false, rememberBrowser:false);

                    // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    //return RedirectToAction("Index", "Home");

                    //Noget jeg har tilføjet til koden!!

                    Sunddk.Utilities.Calculate utilitie = new Utilities.Calculate();

                    double BMR = utilitie.CalculateBMR(model.DateOfBirth, model.Gender, model.Weight, model.Height);

                    var measurment = new Models.Measurement();
                    measurment.Date = DateTime.Now.Date;
                    measurment.Weight = model.Weight;
                    measurment.Height = model.Height;
                    measurment.BMR = BMR;

                    using (var db = new Models.MealPlanContext()) {
                        var Person = new Models.Person();
                        Person.Name = model.Name;
                        Person.DateOfBirth = model.DateOfBirth;
                        Person.IsAdmin = model.IsAdmin;
                        Person.Gender = model.Gender;
                        Person.Email = model.Email;
                        Person.Password = model.Password;
                        Person.Measurements = new List<Models.Measurement>();
                        Person.Measurements.Add(measurment);
                        db.Persons.Add(Person);
                        db.SaveChanges();
                    }

                    return RedirectToAction("UserProfile", "User", new { Email = model.Email });
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }