Beispiel #1
0
        /// <summary>
        /// API Service call to add employee
        /// </summary>
        /// <param name="Employee"></param>
        /// <returns>Added API response</returns>
        public static async Task <string> Post(EmployeeAdd newEmployee)
        {
            using (client = new HttpClient())
            {
                client.DefaultRequestHeaders.Add("Authorization", "Bearer " + APItoken);
                using (HttpResponseMessage response = await client.PostAsJsonAsync <EmployeeAdd>(baseURL + "users" + "?api_key = " + APItoken, newEmployee))
                {
                    if (response.IsSuccessStatusCode)
                    {
                        using (HttpContent content = response.Content)
                        {
                            string employeeJsonString = await content.ReadAsStringAsync();

                            if (employeeJsonString != null)
                            {
                                return(employeeJsonString);
                            }
                        }
                    }
                    else
                    {
                        throw new Exception(response.ReasonPhrase);
                    }
                }
            }
            return(string.Empty);
        }
Beispiel #2
0
        // 직원 등록 버튼
        private void btn_Add_Click_1(object sender, EventArgs e)
        {
            EmployeeAdd ea = new EmployeeAdd();

            ea.Owner = this;
            ea.Show();
        }
        public EmployeeBase AddEmployee(EmployeeAdd newItem)
        {
            // Call the web service method
            var addedItem = es.AddEmployee(newItem);

            return (addedItem == null) ? null : addedItem;
        }
        public void E2E1_AddEmployee()
        {
            Index       indexPage  = new Index(_driver, BASE_URL, _wait);
            INavigation navigation = indexPage.Open();

            indexPage.GoToEmployees();

            EmployeesList listPage = new EmployeesList(_driver, BASE_URL, _wait);

            listPage.NewEmployeeButton.Click();
            listPage.Loading();

            EmployeeAdd addPage = new EmployeeAdd(_driver, BASE_URL, _wait);

            addPage.FillForm("Test Employee", "Test Address", "test@email", "123-456-789");

            addPage.SaveEmployee();

            EmployeeDataRow newEmployee = listPage.GetLast();

            listPage.Loading();

            Assert.AreEqual("Test Employee", newEmployee.Name.Text);
            Assert.AreEqual("Test Address", newEmployee.Address.Text);
            Assert.AreEqual("test@email", newEmployee.Email.Text);
            Assert.AreEqual("123-456-789", newEmployee.PhoneNumber.Text);
        }
        public EmployeeBase EmployeeAddNew(EmployeeAdd newItem)
        {
            // Call the web service method
            var addedItem = es.AddEmployee(newItem);

            return((addedItem == null) ? null : addedItem);
        }
        public ActionResult Add()
        {
            try
            {
                var         objPosition = employeeRepository.GetPosition();
                EmployeeAdd employeeAdd = new EmployeeAdd();

                var savePath = Server.MapPath("~/Uploads/");
                var fileName = "default.jpg";
                employeeAdd.ImageStream = ImageHelper.BaseDateImage(savePath + "/" + fileName);

                var      strValue = "1990-01-01";
                DateTime objDate;
                DateTime.TryParse(strValue, out objDate);
                employeeAdd.Dob = objDate;
                employeeModel   = new EmployeeModels
                {
                    employeeAdd = employeeAdd,
                    checkPost   = false,
                    positions   = objPosition
                };
            }
            catch (Exception ex)
            {
                log.Error(ex);
                ModelState.AddModelError(string.Empty, Translator.UnexpectedError);
            }
            return(View(employeeModel));
        }
Beispiel #7
0
        // POST: api/Employees
        public IHttpActionResult Post([FromBody] EmployeeAdd newItem)
        {
            // Ensure that the URI is clean (and does not have an id parameter)
            if (Request.GetRouteData().Values["id"] != null)
            {
                return(BadRequest("Invalid request URI"));
            }

            // Ensure that a "newItem" is in the entity body
            if (newItem == null)
            {
                return(BadRequest("Must send an entity body with the request"));
            }

            // Ensure that we can use the incoming data
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            // Attempt to add the new object
            var addedItem = m.EmployeeAdd(newItem);

            // Continue?
            if (addedItem == null)
            {
                return(BadRequest("Cannot add the object"));
            }

            // HTTP 201 with the new object in the entity body
            // Notice how to create the URI for the Location header
            var uri = Url.Link("DefaultApi", new { id = addedItem.EmployeeId });

            return(Created(uri, addedItem));
        }
Beispiel #8
0
        // Add new
        public EmployeeBase AddNew(EmployeeAdd newItem)
        {
            // Add the new object
            var addedItem = RAdd(Mapper.Map <Employee>(newItem));

            // Return the object
            return(Mapper.Map <EmployeeBase>(addedItem));
        }
Beispiel #9
0
        // Add new item
        public Employee AddEmployee(EmployeeAdd Employee)
        {
            // Map from DTO object to domain (POCO) object
            var p = ds.Employees.Add(Mapper.Map <ICTGWS.Models.Employee>(Employee));  //<=====

            ds.SaveChanges();
            // Map to DTO object
            return(Mapper.Map <Employee>(p));
        }
Beispiel #10
0
 /// <summary>
 /// 创建一个增加员工
 /// </summary>
 /// <param name="validationErrors">返回的错误信息</param>
 /// <param name="db">数据库上下文</param>
 /// <param name="entity">一个增加员工</param>
 /// <returns></returns>
 public bool Create(ref ValidationErrors validationErrors, EmployeeAdd entity)
 {
     try
     {
         repository.Create(entity);
         return(true);
     }
     catch (Exception ex)
     {
         validationErrors.Add(ex.Message);
         ExceptionsHander.WriteExceptions(ex);
     }
     return(false);
 }
Beispiel #11
0
        public ActionResult EmployeeEdit(string id)
        {
            var EmployeInDb = _context.EmployeeManagements.SingleOrDefault(e => e.Id == id);

            if (EmployeInDb == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            EmployeeAdd employeeAdd = new EmployeeAdd();

            employeeAdd.employeeManagement = EmployeInDb;
            return(View(employeeAdd));
        }
Beispiel #12
0
        public ActionResult EmployeeUpdate(EmployeeAdd employeeAdd)
        {
            var addEmployee = _context.EmployeeManagements.SingleOrDefault(e => e.Id == employeeAdd.employeeManagement.Id);

            addEmployee.Name        = employeeAdd.employeeManagement.Name;
            addEmployee.LastName    = employeeAdd.employeeManagement.LastName;
            addEmployee.JoiningDate = employeeAdd.employeeManagement.JoiningDate;
            addEmployee.Address     = employeeAdd.employeeManagement.Address;
            addEmployee.Contact     = employeeAdd.employeeManagement.Contact;
            addEmployee.Position    = employeeAdd.employeeManagement.Position;
            _context.SaveChanges();

            return(Redirect("~/EmployeeManagement/Index"));
        }
Beispiel #13
0
        public ActionResult AddEmployee(EmployeeAdd Item)
        {
            var add = new EmployeeManagement();



            add          = Item.employeeManagement;
            add.Position = Request.Form["position"];

            _context.EmployeeManagements.Add(add);



            _context.SaveChanges();
            return(Redirect("Index"));
        }
        public ActionResult Create(EmployeeAdd newItem)
        {
            // Validate the input
            if (!ModelState.IsValid) { return View(); }

            // Process the input
            var addedItem = m.AddEmployee(newItem);

            if (addedItem == null)
            {
                return View(newItem);
            }
            else
            {
                return RedirectToAction("details", new { id = addedItem.Id });
            }
        }
Beispiel #15
0
        private void btnSubmitEmployee_Click(object sender, EventArgs e)
        {
            Service = new WebAPIHelper("http://localhost:61732/", "api/Employees");


            //string PasswordHash= ;
            // = ;
            //int CityID = SelectedCity.CityID;
            //string datetime=dtpBirthDate.Value.ToString();

            dynamic SelectedCity = cmbCities.SelectedItem;

            string PasswordSalt = UIHelper.GenerateSalt();


            EmployeeAdd obj = new EmployeeAdd();

            obj.FirstName       = txtFirstName.Text;
            obj.LastName        = txtLastName.Text;
            obj.CityBirthID     = Int32.Parse(cmbCities.SelectedValue.ToString());
            obj.BirthDate       = dtpBirthDate.Value;
            obj.Gender          = (cmbGender.SelectedItem.ToString() == "Male") ? false : true;
            obj.CurriculumVitae = txtCurriculumVitae.Text;
            obj.Email           = txtEmail.Text;
            obj.Username        = txtUsername.Text;
            obj.PhoneNumber     = txtPhoneNumber.Text;
            obj.PasswordSalt    = PasswordSalt;
            obj.PasswordHash    = UIHelper.GenerateHash(txtPassword.Text, PasswordSalt);
            obj.IsDeleted       = false;



            HttpResponseMessage Response = Service.PostResponse(obj);

            if (Response.IsSuccessStatusCode)
            {
                MessageBox.Show("Employee added successfully!");
                DialogResult = DialogResult.OK;
                Close();
            }
            else
            {
                MessageBox.Show("Error status code: " + Response.StatusCode + " Message: " + Response.ReasonPhrase);
            }
        }
        public ActionResult Create(EmployeeAdd newItem)
        {
            // Validate the input
            if (!ModelState.IsValid)
            {
                return(View());
            }

            // Process the input
            var addedItem = m.EmployeeAddNew(newItem);

            if (addedItem == null)
            {
                return(View(newItem));
            }
            else
            {
                return(RedirectToAction("details", new { id = addedItem.Id }));
            }
        }
        public EmployeeBase AddEmployee(EmployeeAdd newItem)
        {
            // Attention 10 - Can copy most of the logic from the EmployeesController (Web API)

            // Ensure that a "newItem" is in the entity body
            if (newItem == null)
            {
                return(null);
            }

            // Ensure that we can use the incoming data

            // Attention 11 - We do not have access to ModelState in this kind of class
            // However, we can add it in...

            var vc = new ValidationContext(newItem, null, null);
            var modelStateIsValid = Validator.TryValidateObject(newItem, vc, null, true);

            if (modelStateIsValid)
            {
                // Attempt to add the new object
                var addedItem = m.EmployeeAdd(newItem);

                // Notice the ApiController convenience methods
                if (addedItem == null)
                {
                    return(null);
                }
                else
                {
                    // Return the new object in the entity body
                    return(addedItem);
                }
            }
            else
            {
                return(null);
            }
        }
Beispiel #18
0
        /// <summary>
        /// Event to handle adding new employee
        /// </summary>
        private async void btnEmpAdd_Click(object sender, EventArgs e)
        {
            try
            {
                if (ValidateControls((Button)sender))
                {
                    EmployeeAdd newEmployee = new EmployeeAdd();
                    newEmployee.name   = txtEmpName.Text.Trim();
                    newEmployee.email  = txtEmpEmail.Text.Trim();
                    newEmployee.gender = cboEmpGender.SelectedItem.ToString();
                    newEmployee.status = cboEmpStatus.SelectedItem.ToString();
                    var response = await RESTApiHelper.Post(newEmployee);

                    //DeserializeJsonforSingleSearch(response);
                    LoadCurrentPage(Convert.ToInt32(lblPages.Text));
                    //ListAllEmployees();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, AppName);
            }
        }
Beispiel #19
0
 /// <summary>
 /// 报增保险。不更新数据库
 /// </summary>
 /// <param name="db">实体类</param>
 /// <param name="entity">初始值</param>
 /// <returns></returns>
 public bool CreateEmployee(SysEntities entities, EmployeeAdd entity)
 {
     repository.Create(entities, entity);
     return(true);
 }
        private void addEmployee_Click(object sender, EventArgs e)
        {
            EmployeeAdd ob = new EmployeeAdd();

            ob.Show();
        }
Beispiel #21
0
        /// <summary>
        /// 创建
        /// </summary>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public Common.ClientResult.Result Post(string parameters)
        {
            Common.ClientResult.Result result = new Common.ClientResult.Result();
            if (!string.IsNullOrEmpty(parameters))
            {
                List <EmployeeStopPaymentSingle> list = new List <EmployeeStopPaymentSingle>();
                string[] kinds = parameters.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string kind in kinds)
                {
                    string[] param = kind.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);//EmployeeAddID,社保月,报减类型,报减自然月,险种,政策,企业员工关系

                    // 获取报增信息,判断是否为供应商的,若为供应商的,则状态设为“待供应商客服提取”
                    IBLL.IEmployeeAddBLL add_bll          = new EmployeeAddBLL();
                    EmployeeAdd          employeeAddModel = add_bll.GetById(Convert.ToInt32(param[0])); // param[0]为EmployeeAddId
                    string stopStatus = employeeAddModel.SuppliersId == null?EmployeeStopPayment_State.待员工客服确认.ToString() : EmployeeStopPayment_State.待供应商客服提取.ToString();

                    EmployeeStopPaymentSingle single = new EmployeeStopPaymentSingle()
                    {
                        InsuranceKindId           = Convert.ToInt32(param[4]),
                        PoliceInsuranceId         = Convert.ToInt32(param[5]),
                        CompanyEmployeeRelationId = Convert.ToInt32(param[6]),
                        StopPayment = new EmployeeStopPayment()
                        {
                            EmployeeAddId     = Convert.ToInt32(param[0]),
                            InsuranceMonth    = Convert.ToDateTime(param[1] + "-01"),
                            PoliceOperationId = Convert.ToInt32(param[2]),
                            //State = EmployeeStopPayment_State.待员工客服确认.ToString(),
                            State        = stopStatus,
                            YearMonth    = Convert.ToInt32(param[3].Replace("-", "")),
                            CreateTime   = DateTime.Now,
                            CreatePerson = LoginInfo.UserName,
                            UpdateTime   = DateTime.Now,
                            UpdatePerson = LoginInfo.UserName,
                        },
                    };
                    list.Add(single);
                }


                //string currentPerson = GetCurrentPerson();
                //entity.CreateTime = DateTime.Now;
                //entity.CreatePerson = currentPerson;


                string returnValue = string.Empty;
                if (m_BLL.InsertStopPayment(list))
                {
                    //LogClassModels.WriteServiceLog(Suggestion.InsertSucceed + ",员工停缴的信息的Id为" + entity.Id, "员工停缴");//写入日志
                    result.Code    = Common.ClientCode.Succeed;
                    result.Message = Suggestion.InsertSucceed;
                    return(result); //提示创建成功
                }
                else
                {
                    if (validationErrors != null && validationErrors.Count > 0)
                    {
                        validationErrors.All(a =>
                        {
                            returnValue += a.ErrorMessage;
                            return(true);
                        });
                    }
                    LogClassModels.WriteServiceLog(Suggestion.InsertFail + ",员工停缴的信息," + returnValue, "员工停缴");//写入日志
                    result.Code    = Common.ClientCode.Fail;
                    result.Message = Suggestion.InsertFail + returnValue;
                    return(result); //提示插入失败
                }
            }

            result.Code    = Common.ClientCode.FindNull;
            result.Message = Suggestion.InsertFail + ",请核对输入的数据的格式"; //提示输入的数据的格式不对
            return(result);
        }
Beispiel #22
0
 public string ChangeServicecharge(EmployeeAdd item, string message, string LoginName)
 {
     return(repository.ChangeServicecharge(db, item, message, LoginName));
 }
Beispiel #23
0
        protected override void Seed(Notes.Models.ApplicationDbContext context)
        {
            // Add the initial 'admin' user...
            if (context.Users.Count() == 0)
            {
                // First, initialize a user manager
                var um = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(context));

                // Attempt to create an 'admin' user
                var admin = new ApplicationUser {
                    FirstName = "App", LastName = "Administrator", UserName = "******", Email = "*****@*****.**"
                };
                var result = um.Create(admin, "Password123!");

                // Attempt to add role claims
                if (result.Succeeded)
                {
                    um.AddClaim(admin.Id, new Claim(ClaimTypes.Email, admin.Email));
                    um.AddClaim(admin.Id, new Claim(ClaimTypes.GivenName, admin.FirstName));
                    um.AddClaim(admin.Id, new Claim(ClaimTypes.Surname, admin.LastName));
                    um.AddClaim(admin.Id, new Claim(ClaimTypes.Role, "Administrator"));
                }
            }

            // Add the 'organizational units' and the 'employees'

            // Create a reference to the app's data manager
            Controllers.Manager m = new Controllers.Manager();

            // Load the OUs
            if (context.OUs.Count() == 0)
            {
                // Add some OUs...
                context.OUs.Add(new OU {
                    OUName = "Executive Office"
                });
                context.OUs.Add(new OU {
                    OUName = "Electrical"
                });
                context.OUs.Add(new OU {
                    OUName = "Editorial"
                });
                context.OUs.Add(new OU {
                    OUName = "Research & Development"
                });
                context.OUs.Add(new OU {
                    OUName = "Talent"
                });
                context.OUs.Add(new OU {
                    OUName = "Human Resources"
                });
                context.OUs.Add(new OU {
                    OUName = "Production"
                });
                context.OUs.Add(new OU {
                    OUName = "Creative"
                });

                context.SaveChanges();
            }

            // Load the Employees
            if (context.Employees.Count() == 0)
            {
                // File system path to the data file (in this project's App_Data folder)
                // Not yet tested with Azure - if it is problematic...
                // ...contact your professor for help (or with the solution)
                string path = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/Employees.csv");

                // Create a stream reader object, to read from the file system
                StreamReader sr = File.OpenText(path);

                // Create the CsvHelper object
                var csv = new CsvReader(sr);

                // Create the AutoMapper mapping
                Mapper.CreateMap <Controllers.EmployeeAdd, Models.Employee>();

                // Go through the data file
                while (csv.Read())
                {
                    // Read one line in the source file
                    EmployeeAdd newItem = csv.GetRecord <EmployeeAdd>();

                    // Create a new employee object
                    Employee addedItem = Mapper.Map <Employee>(newItem);

                    // Add the new object to the data store
                    context.Employees.Add(addedItem);
                }

                context.SaveChanges();

                // Clean up
                sr.Close();
                sr = null;
            }
        }
Beispiel #24
0
        /// <summary>
        /// 模板设置报增失败
        /// </summary>
        /// <param name="dt">Excel数据</param>
        /// <param name="userID">操作人ID</param>
        /// <param name="userName">操作人姓名</param>
        /// <returns></returns>
        public string SetAddFailByExcel(DataTable dt, int userID, string userName)
        {
            try
            {
                string             result          = "";
                List <EmployeeAdd> EmployeeAddList = new List <EmployeeAdd>();
                List <string>      failMsgList     = new List <string>();
                #region  验证
                //校验数据是否可操作

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    #region 数据验证
                    string tmpmsg = chkExcel(dt.Rows[i]);

                    if (tmpmsg != "")
                    {
                        result += "第" + (i + 1) + "行," + tmpmsg + "<br/>";
                        continue;
                    }

                    #endregion

                    #region 业务验证

                    string[] InKind   = dt.Rows[i]["险种"].ToString().Split(';');
                    string   cardid   = dt.Rows[i]["证件号码"].ToString();
                    string   username = dt.Rows[i]["姓名"].ToString();
                    string   cityname = dt.Rows[i]["社保缴纳地"].ToString();
                    string   failMsg  = dt.Rows[i]["失败原因"].ToString();

                    for (int j = 0; j < InKind.Length; j++)
                    {
                        EmployeeAdd addModel = new EmployeeAdd();
                        int         rst      = repository.CheckApprove(cardid, username, Common.EnumsCommon.GetInsuranceKindValue(InKind[j]), cityname, userID, ref addModel);

                        if (rst == 1)
                        {
                            result += "第" + (i + 1) + "行,该员工不存在!<br/>";
                        }
                        else if (rst == 2)
                        {
                            result += "第" + (i + 1) + "行,【" + InKind[j] + "】没有可操作报增记录!<br/>";
                        }
                        else if (rst == 3)
                        {
                            result += "第" + (i + 1) + "行,没有操作【" + cityname + InKind[j] + "】的权限!<br/>";
                        }
                        else if (rst == 0)
                        {
                            EmployeeAddList.Add(addModel);
                            failMsgList.Add(failMsg);
                        }
                        else
                        {
                            result += "第" + (i + 1) + "行,未知错误<br/>";
                        }
                    }
                    #endregion
                }
                #endregion

                #region 写数据

                if (result == "")
                {
                    using (TransactionScope scope = new TransactionScope())
                    {
                        using (db)
                        {
                            for (int i = 0; i < EmployeeAddList.Count; i++)
                            {
                                EmployeeAdd item    = EmployeeAddList[i];
                                string      message = failMsgList[i];
                                result = repository.ChangeServicecharge(db, item, message, userName);
                                db.SaveChanges();
                            }
                            scope.Complete();
                        }
                    }
                }

                #endregion

                return(result);
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
Beispiel #25
0
        public ActionResult CalculateAddedSalary(EmployeeAdd Item)
        {
            bool check = false;
            List <EmployeeSalary> employees = _context.EmployeeSalaries.ToList();

            for (int i = 0; i < employees.Count(); i++)
            {
                var EmpID = Item.employeeManagement.Id;
                var Month = Request.Form["month"];
                var Year  = Request.Form["year"];


                if ((employees[i].Id.Equals(EmpID) && (employees[i].Month.Equals(Month) && (employees[i].Year.Equals(Year)))))
                {
                    check = true;
                }
            }
            var add = new EmployeeSalary();

            if (check == false)
            {
                var emplID = new EmployeeSalary();

                emplID.Id        = Item.employeeManagement.Id;
                emplID.Month     = Request.Form["month"];
                emplID.Year      = Request.Form["year"];
                emplID.Allowance = Request.Form["allowance"];
                emplID.WDays     = Request.Form["Wdays"];
                try
                {
                    var checkPosition = Item.employeeManagement.Position;
                    if (checkPosition.Equals("Manager"))
                    {
                        float calculation1 = Int32.Parse(emplID.WDays) * 1800;
                        float TotalSalary1 = Int32.Parse(emplID.Allowance) + calculation1;
                        emplID.Total = TotalSalary1.ToString();
                    }
                    else if (checkPosition.Equals("Worker"))
                    {
                        float calculation1 = Int32.Parse(emplID.WDays) * 1000;
                        float TotalSalary1 = Int32.Parse(emplID.Allowance) + calculation1;
                        emplID.Total = TotalSalary1.ToString();
                    }

                    else if (checkPosition.Equals("Manager"))
                    {
                        float calculation1 = Int32.Parse(emplID.WDays) * 2500;
                        float TotalSalary1 = Int32.Parse(emplID.Allowance) + calculation1;
                        emplID.Total = TotalSalary1.ToString();
                    }
                    else
                    {
                        return(Redirect("Index"));
                    }



                    //     float calculation = Int32.Parse(emplID.WDays) * 1000;
                    //    float TotalSalary = Int32.Parse(emplID.Allowance) + calculation;
                    //    emplID.Total = TotalSalary.ToString();

                    _context.EmployeeSalaries.Add(emplID);
                    _context.SaveChanges();
                }
                catch (Exception e)
                {
                    return(Redirect("Index"));
                }
            }


            _context.SaveChanges();
            return(Redirect("~/EmployeeManagement/SalaryDetail"));
        }
        private void إضافةموظفجديدToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            EmployeeAdd addEmpForm = new EmployeeAdd();

            addEmpForm.ShowDialog();
        }
Beispiel #27
0
        protected override void Seed(PropertyManager.Models.ApplicationDbContext context)
        {
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method
            //  to avoid creating duplicate seed data. E.g.
            //
            //    context.People.AddOrUpdate(
            //      p => p.FullName,
            //      new Person { FullName = "Andrew Peters" },
            //      new Person { FullName = "Brice Lambson" },
            //      new Person { FullName = "Rowan Miller" }
            //    );
            //


            if (!(context.Users.Any(u => u.UserName == "*****@*****.**")))
            {
                var userStore    = new UserStore <ApplicationUser>(context);
                var userManager  = new UserManager <ApplicationUser>(userStore);
                var userToInsert = new ApplicationUser
                {
                    UserName  = "******",
                    Email     = "*****@*****.**",
                    GivenName = "Amanda",
                    Surname   = "Cruz",
                    Role      = "Manager"
                };
                userManager.Create(userToInsert, "PropertyApp123");
                userManager.AddClaim(userToInsert.Id, new Claim(ClaimTypes.Role, "Manager"));
            }

            if (!(context.Users.Any(u => u.UserName == "*****@*****.**")))
            {
                var userStore    = new UserStore <ApplicationUser>(context);
                var userManager  = new UserManager <ApplicationUser>(userStore);
                var userToInsert = new ApplicationUser
                {
                    UserName  = "******",
                    Email     = "*****@*****.**",
                    GivenName = "Administrator",
                    Surname   = "Adm",
                    Role      = "Administrator"
                };
                userManager.Create(userToInsert, "PropertyApp123");
                userManager.AddClaim(userToInsert.Id, new Claim(ClaimTypes.Role, "Administrator"));
            }


            if (!(context.Users.Any(u => u.UserName == "*****@*****.**")))
            {
                var userStore    = new UserStore <ApplicationUser>(context);
                var userManager  = new UserManager <ApplicationUser>(userStore);
                var userToInsert = new ApplicationUser
                {
                    UserName  = "******",
                    Email     = "*****@*****.**",
                    GivenName = "Amanda",
                    Surname   = "Marques",
                    Role      = "Tenant"
                };
                userManager.Create(userToInsert, "Asdf4321!");
                userManager.AddClaim(userToInsert.Id, new Claim(ClaimTypes.Role, "Tenant"));
            }

            //UNIT
            if (m.UnitGetAll().Count() == 0)
            {
                var unit = new UnitAdd();

                unit.Bedrooms     = 2;
                unit.Bathrooms    = 1;
                unit.SquareFeet   = 100.5;
                unit.MaxOccupants = 3;
                unit.Balcony      = true;
                unit.Dishwasher   = true;
                unit.Laundry      = false;
                m.UnitAdd(unit);

                unit.Bedrooms     = 1;
                unit.Bathrooms    = 1;
                unit.SquareFeet   = 87.5;
                unit.MaxOccupants = 2;
                unit.Balcony      = true;
                unit.Dishwasher   = false;
                unit.Laundry      = false;
                m.UnitAdd(unit);

                unit.Bedrooms     = 3;
                unit.Bathrooms    = 2;
                unit.SquareFeet   = 130.0;
                unit.MaxOccupants = 5;
                unit.Balcony      = true;
                unit.Dishwasher   = true;
                unit.Laundry      = true;
                m.UnitAdd(unit);
            }

            if (m.ApartmentGetAll().Count() == 0)
            {
                var apt = new ApartmentAdd();

                apt.ApartmentNumber = 520;
                apt.FloorNumber     = 5;
                apt.Status          = "Occupied";
                apt.UnitId          = 1;

                m.ApartmentAdd(apt);

                apt.ApartmentNumber = 603;
                apt.FloorNumber     = 6;
                apt.Status          = "Occupied";
                apt.UnitId          = 2;

                m.ApartmentAdd(apt);

                apt.ApartmentNumber = 1705;
                apt.FloorNumber     = 17;
                apt.Status          = "Occupied";
                apt.UnitId          = 3;

                m.ApartmentAdd(apt);
            }

            if (m.TenantGetAll().Count() == 0)
            {
                var tenant = new TenantAdd();

                tenant.FirstName   = "Amanda";
                tenant.LastName    = "Marques";
                tenant.MobilePhone = "647-535-7732";
                tenant.HomePhone   = "";
                tenant.Email       = "*****@*****.**";
                tenant.BirthDate   = new DateTime(1988, 12, 23);
                m.TenantAdd(tenant);

                tenant.FirstName   = "Jonathan";
                tenant.LastName    = "Desmond";
                tenant.MobilePhone = "536-85-96415";
                tenant.HomePhone   = "365-459-8752";
                tenant.Email       = "*****@*****.**";
                tenant.BirthDate   = new DateTime(1990, 10, 18);
                m.TenantAdd(tenant);

                tenant.FirstName   = "Carlos";
                tenant.LastName    = "Wellinton";
                tenant.MobilePhone = "963-125-4789";
                tenant.HomePhone   = "964-585-3658";
                tenant.Email       = "*****@*****.**";
                tenant.BirthDate   = new DateTime(1994, 09, 21);
                m.TenantAdd(tenant);
            }

            if (m.LeaseGetAllWithInformation().Count() == 0)
            {
                var lease = new LeaseAdd();
                lease.StartDate       = new DateTime(2016, 01, 01);
                lease.EndDate         = new DateTime(2018, 01, 01);
                lease.SecurityDeposit = 500.00;
                lease.MonthlyRent     = 1050.60;
                lease.ApartmentNumber = 520;
                lease.TenantId        = 1;

                m.LeaseAdd(lease);

                lease.StartDate       = new DateTime(2017, 08, 20);
                lease.EndDate         = new DateTime(2018, 08, 19);
                lease.SecurityDeposit = 430.00;
                lease.MonthlyRent     = 1200.50;
                lease.ApartmentNumber = 603;
                lease.TenantId        = 2;

                m.LeaseAdd(lease);

                lease.StartDate       = new DateTime(2016, 04, 01);
                lease.EndDate         = new DateTime(2017, 04, 01);
                lease.SecurityDeposit = 525.00;
                lease.MonthlyRent     = 1400.80;
                lease.ApartmentNumber = 1705;
                lease.TenantId        = 3;
                m.LeaseAdd(lease);
            }

            if (m.EmployeeGetAll().Count() == 0)
            {
                var employee = new EmployeeAdd();
                employee.LastName   = "Marques";
                employee.FirstName  = "Amanda";
                employee.Title      = "Supervisor";
                employee.BirthDate  = new DateTime(1988, 12, 23);
                employee.HireDate   = new DateTime(2017, 02, 06);
                employee.Address    = "Wellesley St";
                employee.City       = "Toronto";
                employee.State      = "ON";
                employee.Country    = "Canada";
                employee.PostalCode = "M4X-1G5";
                employee.Email      = "*****@*****.**";
                employee.Phone      = "647-589-5357";
                m.EmployeeAdd(employee);

                employee.LastName   = "Desmond";
                employee.FirstName  = "Jonathan";
                employee.Title      = "Manager";
                employee.BirthDate  = new DateTime(1990, 11, 16);
                employee.HireDate   = new DateTime(2017, 01, 05);
                employee.Address    = "Pond Rd";
                employee.City       = "Toronto";
                employee.State      = "ON";
                employee.Country    = "Canada";
                employee.PostalCode = "M6H 1Y7";
                employee.Email      = "*****@*****.**";
                employee.Phone      = "647-896-5236";
                m.EmployeeAdd(employee);

                employee.LastName   = "Capello";
                employee.FirstName  = "Silvia";
                employee.Title      = "Clerk";
                employee.BirthDate  = new DateTime(1958, 01, 09);
                employee.HireDate   = new DateTime(2016, 04, 28);
                employee.Address    = "Aluisio St";
                employee.City       = "Toronto";
                employee.State      = "ON";
                employee.Country    = "Canada";
                employee.PostalCode = "J7G 1S3";
                employee.Email      = "*****@*****.**";
                employee.Phone      = "647-652-3105";
                m.EmployeeAdd(employee);
            }

            if (m.AnnouncementGetAll().Count() == 0)
            {
                var announce = new AnnouncementAdd();
                announce.Title       = "Laundry closed";
                announce.StartDate   = new DateTime(2017, 05, 05);
                announce.ExpireDate  = new DateTime(2017, 05, 06);
                announce.Description = "The laundry room will be closed for maintenance";
                m.AnnouncementAdd(announce);

                announce.Title       = "Cleaning of corridor";
                announce.StartDate   = new DateTime(2017, 04, 20);
                announce.ExpireDate  = new DateTime(2017, 04, 22);
                announce.Description = "The carpet will be cleaned on the upcoming weekend";
                m.AnnouncementAdd(announce);

                announce.Title       = "New Recycle Bins";
                announce.StartDate   = new DateTime(2017, 03, 10);
                announce.ExpireDate  = new DateTime(2017, 03, 11);
                announce.Description = "The apartments will be receiving new recycle bins starting next week";
                m.AnnouncementAdd(announce);
            }

            if (m.FacilityGetAll().Count() == 0)
            {
                var facility = new FacilityAdd();
                facility.FacilityName = "Pool";
                facility.Description  = "Open Pool";
                facility.Location     = "40th floor";
                facility.Status       = "Open";
                facility.OpenTime     = new DateTime(2017, 01, 01, 08, 0, 0);
                facility.CloseTime    = new DateTime(2017, 02, 01, 18, 0, 0);
                m.FacilityAdd(facility);

                facility.FacilityName = "Movie Room";
                facility.Description  = "Movie Theater";
                facility.Location     = "Lobby";
                facility.Status       = "Open";
                facility.OpenTime     = new DateTime(2017, 02, 01, 10, 0, 0);
                facility.CloseTime    = new DateTime(2017, 02, 01, 20, 30, 0);
                m.FacilityAdd(facility);
            }

            if (m.InventoryGetAll().Count() == 0)
            {
                var inventory = new InventoryAdd();
                inventory.ProductName = "Cleaning";
                inventory.Supplier    = "Lisol";
                inventory.Quantity    = 20;
                m.InventoryAdd(inventory);

                inventory.ProductName = "Garbage Bag";
                inventory.Supplier    = "My Garbages";
                inventory.Quantity    = 100;
                m.InventoryAdd(inventory);

                inventory.ProductName = "Window cleaning";
                inventory.Supplier    = "Windex";
                inventory.Quantity    = 87;
                m.InventoryAdd(inventory);
            }

            if (m.ServiceGetAll().Count() == 0)
            {
                var service = new ServiceAdd();
                service.ServiceName = "Gardening";
                service.CompanyName = "Gardening Express";
                service.PhoneNumber = "416-547-8963";
                service.Email       = "*****@*****.**";
                service.Address     = "346 Allen Rd";
                m.ServiceAdd(service);

                service.ServiceName = "Pest Control";
                service.CompanyName = "Pest Rock";
                service.PhoneNumber = "647-514-8965";
                service.Email       = "*****@*****.**";
                service.Address     = "1549 Dufferin St";
                m.ServiceAdd(service);

                service.ServiceName = "Cleaning";
                service.CompanyName = "Nice Cleaning";
                service.PhoneNumber = "907-534-8698";
                service.Email       = "*****@*****.**";
                service.Address     = "15 Bloor St";
                m.ServiceAdd(service);
            }

            if (m.WorkOrderGetAll().Count() == 0)
            {
                var workOrder = new WorkOrderAdd();
                workOrder.Description = "Fixing light bulb";
                workOrder.Notes       = "In the living room";
                workOrder.RequestDate = new DateTime(2017, 02, 26);
                workOrder.TenantId    = 1;
                m.WorkOrderAdd(workOrder);

                workOrder.Description = "Kill bugs";
                workOrder.Notes       = "Many bugs in the house";
                workOrder.RequestDate = new DateTime(2017, 04, 05);
                workOrder.TenantId    = 2;
                m.WorkOrderAdd(workOrder);

                workOrder.Description = "Leaking in the kitchen";
                workOrder.Notes       = "My sink is full of water";
                workOrder.RequestDate = new DateTime(2017, 05, 22);
                workOrder.TenantId    = 3;
                m.WorkOrderAdd(workOrder);
            }

            if (m.ServiceRequestGetAll().Count() == 0)
            {
                var request = new ServiceRequestAdd();
                request.Description = "Monthly Cleaning";
                request.RequestDate = new DateTime(2017, 03, 01);
                request.ServiceId   = 3;
                m.ServiceRequestAdd(request);

                request.Description = "Doing gardening";
                request.RequestDate = new DateTime(2016, 05, 05);
                request.ServiceId   = 1;
                m.ServiceRequestAdd(request);

                request.Description = "Building Pest Control";
                request.RequestDate = new DateTime(2017, 04, 23);
                request.ServiceId   = 2;
                m.ServiceRequestAdd(request);
            }

            if (m.FacilityBookingGetAllWithFacility().Count() == 0)
            {
                var booking = new FacilityBookingAdd();

                booking.BookedDate = new DateTime(2017, 05, 22);
                booking.StartTime  = new DateTime(2017, 05, 22, 10, 30, 0);
                booking.EndTime    = new DateTime(2017, 05, 22, 17, 0, 0);
                booking.TenantId   = 1;
                booking.FacilityId = 1;
                booking.Notes      = "No Notes";
                m.FacilityBookingAdd(booking);

                booking.BookedDate = new DateTime(2017, 10, 01);
                booking.StartTime  = new DateTime(2017, 10, 01, 13, 0, 0);
                booking.EndTime    = new DateTime(2017, 10, 01, 14, 45, 0);
                booking.TenantId   = 2;
                booking.FacilityId = 2;
                booking.Notes      = "";
                m.FacilityBookingAdd(booking);

                booking.BookedDate = new DateTime(2017, 10, 01);
                booking.StartTime  = new DateTime(2017, 10, 01, 15, 0, 0);
                booking.EndTime    = new DateTime(2017, 10, 01, 18, 0, 0);
                booking.TenantId   = 3;
                booking.FacilityId = 2;
                booking.Notes      = "";
                m.FacilityBookingAdd(booking);

                booking.BookedDate = new DateTime(2017, 04, 05);
                booking.StartTime  = new DateTime(2017, 04, 05, 10, 0, 0);
                booking.EndTime    = new DateTime(2017, 04, 05, 13, 10, 0);
                booking.TenantId   = 1;
                booking.FacilityId = 2;
                booking.Notes      = "";
                m.FacilityBookingAdd(booking);
            }

            if (m.OccupantGetAll().Count() == 0)
            {
                var occupant = new OccupantAdd();

                occupant.FirstName       = "Silvia";
                occupant.LastName        = "Capello";
                occupant.MobilePhone     = "647-415-8957";
                occupant.WorkPhone       = "416-548-9569";
                occupant.Email           = "*****@*****.**";
                occupant.BirthDate       = new DateTime(1958, 01, 09);
                occupant.ApartmentNumber = 520;
                occupant.TenantId        = 1;
                m.OccupantAdd(occupant);

                occupant.FirstName       = "Renan";
                occupant.LastName        = "Marques";
                occupant.MobilePhone     = "647-485-9874";
                occupant.WorkPhone       = "416-123-5647";
                occupant.Email           = "*****@*****.**";
                occupant.BirthDate       = new DateTime(1990, 07, 02);
                occupant.ApartmentNumber = 520;
                occupant.TenantId        = 1;
                m.OccupantAdd(occupant);

                occupant.FirstName       = "Jennifer";
                occupant.LastName        = "Aniston";
                occupant.MobilePhone     = "905-452-7415";
                occupant.WorkPhone       = "416-987-4256";
                occupant.Email           = "*****@*****.**";
                occupant.BirthDate       = new DateTime(1992, 03, 20);
                occupant.ApartmentNumber = 603;
                occupant.TenantId        = 2;
                m.OccupantAdd(occupant);

                occupant.FirstName       = "Mayra";
                occupant.LastName        = "Borne";
                occupant.MobilePhone     = "905-471-3589";
                occupant.WorkPhone       = "416-416-8526";
                occupant.Email           = "*****@*****.**";
                occupant.BirthDate       = new DateTime(2000, 05, 21);
                occupant.ApartmentNumber = 603;
                occupant.TenantId        = 2;
                m.OccupantAdd(occupant);

                occupant.FirstName       = "Tania";
                occupant.LastName        = "Wellinton";
                occupant.MobilePhone     = "905-965-7854";
                occupant.WorkPhone       = "364-654-5984";
                occupant.Email           = "*****@*****.**";
                occupant.BirthDate       = new DateTime(1960, 03, 27);
                occupant.ApartmentNumber = 1705;
                occupant.TenantId        = 3;
                m.OccupantAdd(occupant);
            }
        }
 private void button1_Click(object sender, EventArgs e)
 {
     EmployeeAdd aa = new EmployeeAdd();
     aa.Show();
 }