public UserDTO AddUpdateUser(UserDTO u)
        {
            var newUser = UserMapper.DTOtoEntityUser(u);

            db.Users.AddOrUpdate(newUser);
            db.SaveChanges();
            return(UserMapper.EntitytoDTOUser(newUser));
        }
        public HouseDTO AddUpdateHouse(HouseDTO u)
        {
            var newHouse = HouseMapper.DTOtoEntityHouse(u);

            db.Houses.AddOrUpdate(newHouse);
            db.SaveChanges();
            return(HouseMapper.EntitytoDTOHouse(newHouse));
        }
        protected override void Seed(CensusContext context)
        {
            User approver = new User {
                Email = "*****@*****.**", Password = "******", FirstName = "Aquib", LastName = "Chiniwala", AadharNumber = "123456789012", Role = Role.Volunteer
            };

            context.Users.Add(approver);
            context.SaveChanges();
        }
Exemplo n.º 4
0
 /// <summary>
 /// function to update user role
 /// </summary>
 /// <param name="userToUpdate">object of the user to be update</param>
 /// <returns></returns>
 public bool UpdateUser(UserDTO userToUpdate)
 {
     using (CensusContext db = new CensusContext())
     {
         try
         {
             UserEntity currentUser = mapper.Map <UserEntity>(userToUpdate);
             if (currentUser != null)
             {
                 db.Users.AddOrUpdate(currentUser);
                 db.SaveChanges();
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         catch (Exception ex)
         {
             throw new DALException("Unable to SignUp User" + ex.Message);
         }
     }
 }
        protected override void Seed(CensusContext context)
        {
            var approver = new UserEntity {
                FirstMidName = "Admin", LastName = "DashBoard", Email = "*****@*****.**", Password = "******", IsApprover = true, ProfileImage = "https://firebasestorage.googleapis.com/v0/b/demoproject-1287a.appspot.com/o/admin.png?alt=media&token=6290a56e-84bb-4909-93f1-131bf9ef9f66", AdhaarNumber = "232323232323", CurrentStatus = 0, ApprovedBy = 0
            };

            context.Users.AddOrUpdate(approver);
            context.SaveChanges();

            var house = new HouseEntity
            {
                ID = 1,
                BuildingAptNumber = "13AB",
                Line1             = "House No : 55",
                StreetName        = "King's Street",
                City              = "Delhi",
                State             = "Delhi",
                HeadOfFamily      = "Mr. AAA",
                OwnershipStatus   = Ownership.Owner,
                NumberOfFloor     = 3,
                NumberOfRooms     = 12,
                CreatedBy         = 1,
                CensusHouseNumber = 132011783695550347
            };

            context.Houses.AddOrUpdate(house);
            house = new HouseEntity
            {
                ID = 1,
                BuildingAptNumber = "15AB",
                Line1             = "Flat No : 55",
                StreetName        = "King's Street",
                City              = "Goa",
                State             = "Goa",
                HeadOfFamily      = "Mr. BBB",
                OwnershipStatus   = Ownership.Owner,
                NumberOfFloor     = 3,
                NumberOfRooms     = 12,
                CreatedBy         = 1,
                CensusHouseNumber = 0000000000000004
            };
            context.Houses.AddOrUpdate(house);
            house = new HouseEntity
            {
                ID = 1,
                BuildingAptNumber = "122AB",
                Line1             = "House No : 523",
                StreetName        = "King's Street",
                City              = "Ahemdabad",
                State             = "Gujrat",
                HeadOfFamily      = "Mr. XXX",
                OwnershipStatus   = Ownership.Owner,
                NumberOfFloor     = 3,
                NumberOfRooms     = 12,
                CreatedBy         = 1,
                CensusHouseNumber = 0000000000000002
            };
            context.Houses.AddOrUpdate(house);
            house = new HouseEntity
            {
                ID = 1,
                BuildingAptNumber = "122AB",
                Line1             = "House No : 120",
                StreetName        = "King's Street",
                City              = "Kanpur",
                State             = "Uttar Pradesh",
                HeadOfFamily      = "Mr. XYZ",
                OwnershipStatus   = Ownership.Owner,
                NumberOfFloor     = 3,
                NumberOfRooms     = 12,
                CreatedBy         = 1,
                CensusHouseNumber = 0000000000000003
            };
            context.Houses.AddOrUpdate(house);
            context.SaveChanges();


            //var person = new PersonEntity
            //{

            //    FullName = "Demo1",
            //    CensusHouseNumber = 0000000000000003,
            //    RelationshipWithOwner = Relationship.Self,
            //    Gender = Gender.Male,
            //    DateOfBirth = DateTime.Parse("30-04-2019 12:00:00 AM"),
            //    MaritalStatus = MaritalStatus.Unmarried,
            //    AgeAtMarriage = 0,
            //    Occupation = "Student",
            //    NatureOfWork = "studying",
            //    CreatedBy = 0
            //};
            //context.Persons.AddOrUpdate(person);
            //person = new PersonEntity
            //{

            //    FullName = "Demo1",
            //    CensusHouseNumber = 0000000000000001,
            //    RelationshipWithOwner = Relationship.Self,
            //    Gender = Gender.Male,
            //    DateOfBirth = DateTime.Parse("30-04-2019 12:00:00 AM"),
            //    MaritalStatus = MaritalStatus.Unmarried,
            //    AgeAtMarriage = 0,
            //    Occupation = "IT",
            //    NatureOfWork = "studying",
            //    CreatedBy = 0
            //};
            //context.Persons.AddOrUpdate(person);
            //person = new PersonEntity
            //{

            //    FullName = "Demo1",
            //    CensusHouseNumber = 132011783695550347,
            //    RelationshipWithOwner = Relationship.Self,
            //    Gender = Gender.Female,
            //    DateOfBirth = DateTime.Parse("30-04-2019 12:00:00 AM"),
            //    MaritalStatus = MaritalStatus.Unmarried,
            //    AgeAtMarriage = 0,
            //    Occupation = "Teacher",
            //    NatureOfWork = "Government Job",
            //    CreatedBy = 0
            //};

            //context.Persons.AddOrUpdate(person);
            //person = new PersonEntity
            //{

            //    FullName = "Demo1",
            //    CensusHouseNumber = 132011783695550347,
            //    RelationshipWithOwner = Relationship.Self,
            //    Gender = Gender.Female,
            //    DateOfBirth = DateTime.Parse("30-04-2019 12:00:00 AM"),
            //    MaritalStatus = MaritalStatus.Unmarried,
            //    AgeAtMarriage = 0,
            //    Occupation = "IT",
            //    NatureOfWork = "private job",
            //    CreatedBy = 0
            //};
            //context.Persons.AddOrUpdate(person);
            //person = new PersonEntity
            //{

            //    FullName = "Demo1",
            //    CensusHouseNumber = 0000000000000002,
            //    RelationshipWithOwner = Relationship.Self,
            //    Gender = Gender.Male,
            //    DateOfBirth = DateTime.Parse("30-04-2019 12:00:00 AM"),
            //    MaritalStatus = MaritalStatus.Unmarried,
            //    AgeAtMarriage = 0,
            //    Occupation = "IT",
            //    NatureOfWork = "private job",
            //    CreatedBy = 0
            //};
            //context.Persons.AddOrUpdate(person);
        }