コード例 #1
0
        public IHttpActionResult PutEmployeeMaster(EmployeeDetail employee)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                EmployeeDetail objEmp = new EmployeeDetail();
                objEmp = objEntity.EmployeeDetails.Find(employee.EmpId);
                if (objEmp != null)
                {
                    objEmp.EmpName     = employee.EmpName;
                    objEmp.Address     = employee.Address;
                    objEmp.Role        = employee.Role;
                    objEmp.DateOfBirth = employee.DateOfBirth;
                    objEmp.DateOfJoin  = employee.DateOfJoin;
                    objEmp.Skills      = employee.Skills;
                    objEmp.Dept        = employee.Dept;
                    objEmp.IsActive    = employee.IsActive;
                }
                int i = this.objEntity.SaveChanges();
            }
            catch (Exception)
            {
                throw;
            }
            return(Ok(employee));
        }
コード例 #2
0
        public IHttpActionResult PutEmaployeeMaster(EmployeeDetail employee)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                EmployeeDetail objEmp = new EmployeeDetail();
                objEmp = objEntity.EmployeeDetails.Find(employee.EmpId);
                if (objEmp != null)
                {
                    objEmp.EmpName     = employee.EmpName;
                    objEmp.AddressLoc  = employee.AddressLoc;
                    objEmp.EmailId     = employee.EmailId;
                    objEmp.DateOfBirth = employee.DateOfBirth;
                    objEmp.Gender      = employee.Gender;
                    objEmp.PinCode     = employee.PinCode;
                }
                int i = this.objEntity.SaveChanges();
            }
            catch (Exception)
            {
                throw;
            }
            return(Ok(employee));
        }
コード例 #3
0
        public async Task <IActionResult> PutEmployeeDetail(int id, EmployeeDetail employeeDetail)
        {
            if (id != employeeDetail.id)
            {
                return(BadRequest());
            }

            _context.Entry(employeeDetail).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EmployeeDetailExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #4
0
        public IHttpActionResult PutEmployeeDetail(string id, EmployeeDetail employeeDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != employeeDetail.Id)
            {
                return(BadRequest());
            }

            db.Entry(employeeDetail).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EmployeeDetailExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #5
0
        public async Task <IActionResult> PostEmployeeDetail([FromBody] EmployeeDetail employeeDetail)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var eId = await _handler.PostEmployeeDetail(employeeDetail);

                    if (eId >= 0)
                    {
                        return(CreatedAtAction("GetEmployeeDetail", new { id = employeeDetail.EId }, employeeDetail));
                    }
                    else
                    {
                        return(NotFound());
                    }
                }
                catch (Exception)
                {
                    return(BadRequest());
                }
            }

            return(BadRequest());
        }
コード例 #6
0
        //public string GetEmployeeById(string EmployeeId)
        //{
        //    using (OrganizationEntities ON = new OrganizationEntities())
        //    {
        //        var data = (from e in ON.EmployeeDetails
        //                    select new
        //                    {
        //                        e.EmployeeID,
        //                        e.EmployeeName,
        //                        e.EmailID,
        //                        e.Phone,
        //                        e.Salary,
        //                        e.City
        //                    }).Where(x=>x.EmployeeID == EmployeeId);

        //        return jsonSerialiser.Serialize(data);
        //    }
        //}

        public async Task <EmployeeDetail> GetEmployeeById(int EmployeeId)
        {
            OrganizationEntities OE  = new OrganizationEntities();
            EmployeeDetail       emp = await OE.EmployeeDetails.FindAsync(EmployeeId.ToString());

            return(emp);
        }
コード例 #7
0
        public ActionResult Edit(EmployeeDetail product, String Id)
        {
            EmployeeDetail productToEdit = context.Find(Id);

            if (productToEdit == null)
            {
                return(HttpNotFound());
            }
            else
            {
                if (!ModelState.IsValid)
                {
                    return(View(product));
                }

                productToEdit.FirstName        = product.FirstName;
                productToEdit.LastName         = product.LastName;
                productToEdit.EmailID          = product.EmailID;
                productToEdit.EmployeeID       = product.EmployeeID;
                productToEdit.EmployeeLocation = product.EmployeeLocation;
                productToEdit.Image            = product.Image;

                context.Commit();

                return(RedirectToAction("Index"));
            }
        }
コード例 #8
0
        public async Task <IActionResult> PutEmployeeDetail(int id, EmployeeDetail employeeDetail)
        {
            if (id != employeeDetail.ID)
            {
                return(BadRequest());
            }

            if (!EmployeeDetailExists(id))
            {
                return(NotFound());
            }

            var result = validate(employeeDetail);

            if (result.Success)
            {
                _context.Entry(employeeDetail).State = EntityState.Modified;

                await _context.SaveChangesAsync();

                return(NoContent());
            }

            return(BadRequest(result.Message));
        }
コード例 #9
0
        public async Task <IActionResult> PersonalDetails(EmployeeDetail employeeDetail)
        {
            if (employeeDetail == null)
            {
                return(NotFound());
            }

            var orgId  = getOrg();
            var userId = User.FindFirst(ClaimTypes.NameIdentifier).Value;

            employeeDetail.UserId         = Guid.Parse(userId);
            employeeDetail.OrganisationId = orgId;

            var empDetails = _context.EmployeeDetails.Where(x => x.Id == employeeDetail.Id).FirstOrDefault();

            empDetails.FirstName     = employeeDetail.FirstName;
            empDetails.MiddleName    = employeeDetail.MiddleName;
            empDetails.LastName      = employeeDetail.LastName;
            empDetails.OtherId       = employeeDetail.OtherId;
            empDetails.Gender        = employeeDetail.Gender;
            empDetails.MaritalStatus = employeeDetail.MaritalStatus;

            empDetails.DateOfBirth = employeeDetail.DateOfBirth;


            _context.Update(empDetails);
            await _context.SaveChangesAsync();


            return(View(empDetails));
        }
コード例 #10
0
        public ActionResult Detail(int id)
        {
            var query = from ti in _context.Employee.Where(s => s.Id == id)
                        from st in _context.Department.Where(j => j.Id == ti.DepartmentId).DefaultIfEmpty()
                        from emp in _context.Employee.Where(s => s.Id == ti.ManagerId).DefaultIfEmpty()
                        select new Employee {
                Id = ti.Id, FirstName = ti.FirstName, LastName = ti.LastName, DepartmentName = st.DepartmentName ?? "unknown", ManagerId = ti.ManagerId, ManagerName = emp.Name ?? "unknown", Age = ti.Age, JoiningDate = ti.JoiningDate, Gender = ti.Gender, Salary = ti.Salary ?? 0
            };
            Employee       employee = query.First();
            EmployeeDetail detail   = new EmployeeDetail();

            detail.BaseEmployee = employee;
            var query2 = from ti in _context.Employee.Where(s => s.ManagerId == id)
                         from st in _context.Department.Where(j => j.Id == ti.DepartmentId).DefaultIfEmpty()
                         select new Employee {
                Id = ti.Id, FirstName = ti.FirstName, LastName = ti.LastName, DepartmentName = st.DepartmentName
            };

            detail.ChildrenEmployeeList = query2.ToList();
            if (employee.ManagerId != null)
            {
                detail.Managers = GetManagers(employee.ManagerId.Value);
            }

            return(View(detail));
        }
コード例 #11
0
        private void button_addEmployee_Click(object sender, EventArgs e)
        {
            string errors = validateEmployeeForm();

            if(errors.Length > 0)
            {
                CommonUtility.showErrorPopUp(errors);
                return;
            }

            long lastEmployeeId = 0;
            if(db.EmployeeDetails.Count() > 0)
                lastEmployeeId = db.EmployeeDetails.Select(x=>x.EmployeeId).Max();

            String employeeName = textBox_employeeName.Text.Trim();

            EmployeeDetail employee = new EmployeeDetail();
            employee.Address = textBox_address.Text.Trim();
            employee.EmployeeId = lastEmployeeId + 1;
            employee.EmployeeName = textBox_employeeName.Text.Trim();
            employee.PhoneNumber = textBox_phoneNumber.Text.Trim();
            employee.Salary = Int32.Parse(textBox_salary.Text.Trim());

            if (employeeImage != null)
            {
                byte[] imageInBytes = CommonUtility.getByteArrayFromImage(employeeImage);
                employee.EmpImage = imageInBytes;
            }
            db.EmployeeDetails.Add(employee);

            db.SaveChanges();

            CommonUtility.showSuccessPopUp("Added "+employeeName+"'s Details Successfully");
            this.Close();
        }
コード例 #12
0
        public ActionResult Edit(int id)
        {
            EmployeeContext empctx = new EmployeeContext();
            EmployeeDetail  ed     = empctx.EmployeeDetails.Single(x => x.Id == id);

            return(View(ed));
        }
コード例 #13
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Name,Email,Address,Mobile,DepartmentID,DesignationID")] EmployeeDetail employeeDetail)
        {
            if (id != employeeDetail.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(employeeDetail);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EmployeeDetailExists(employeeDetail.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DepartmentID"]  = new SelectList(_context.Departments, "ID", "Name", employeeDetail.DepartmentID);
            ViewData["DesignationID"] = new SelectList(_context.Designations, "ID", "Name", employeeDetail.DesignationID);
            return(View(employeeDetail));
        }
コード例 #14
0
        /// <summary>
        /// This is a sample specific finder method for Entity1.
        /// If you want to delete or rename the method think about changing the xml in the BDC model file as well.
        /// </summary>
        /// <param name="id"></param>
        /// <returns>Entity1</returns>
        public static EntityEmployeeData ReadItem(string PersonalNumber)
        {
            EmployeeBasic      basicInfo    = null;
            EmployeeDetail     detailedInfo = null;
            EntityEmployeeData ret          = new EntityEmployeeData();

            SharePointLogger logger  = new SharePointLogger();
            TestConfigTh     config  = new TestConfigTh();
            TestLicense      license = new TestLicense();


            using (EmployeeRepositorySAPDotNet rep = new EmployeeRepositorySAPDotNet(config, logger, license))
            {
                List <EmployeeBasic> empList = rep.getEmployeeBasicList();
                foreach (EmployeeBasic emp in empList)
                {
                    if (emp.PersonalNumber.ToLower().Trim().Equals(PersonalNumber.ToLower().Trim()))
                    {
                        basicInfo = emp;
                    }
                }
                if (basicInfo != null)
                {
                    detailedInfo = rep.getEmployeeDetailedInfo(PersonalNumber);
                }
            }

            if (basicInfo != null)
            {
                ret = new EntityEmployeeData(basicInfo, detailedInfo);
            }

            return(ret);
        }
コード例 #15
0
        public IActionResult PutEmployee(int id, EmployeeDetail employeeDetail)
        {
            if (id != employeeDetail.EmpId)
            {
                return(BadRequest());
            }



            try
            {
                _log4net.Info("Leave Update Details Getting Added");
                if (ModelState.IsValid)
                {
                    var res = _EmpRepository.PutEmployee(id, employeeDetail);


                    return(Ok());
                }
                return(BadRequest());
            }
            catch
            {
                _log4net.Error("Error in Updating Leaves Details");
                return(new NoContentResult());
            }
        }
コード例 #16
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            EmployeeDetail employeeDetail = new EmployeeDetail();

            employeeDetail.FirstName            = firstNameTextBox.Text;
            employeeDetail.LastName             = lastNameTextBox.Text;
            employeeDetail.EmailId              = emailIDTextBox.Text;
            employeeDetail.PhoneNumber          = Convert.ToInt64(phoneNumberTextBox.Text);
            employeeDetail.AlternatePhoneNumber = Convert.ToInt64(alternatePhoneTextBox.Text);
            employeeDetail.Address1             = address1TextBox.Text;
            employeeDetail.Address2             = address2TextBox.Text;
            employeeDetail.HomeCountry          = homeCountryTextBox.Text;
            employeeDetail.CurrentCountry       = currentCountryTextBox.Text;
            employeeDetail.ZipCode              = Convert.ToInt32(zipcodeTextBox.Text);


            ServiceReference1.Service1Client webservice = new ServiceReference1.Service1Client();
            int numberOfRowEffected = webservice.SaveEmployeeData(employeeDetail);

            if (numberOfRowEffected > 0)
            {
                MessageBox.Show("Employee Data Successfully Added");
            }
            else
            {
                MessageBox.Show("Employee Data not Added");
            }
        }
コード例 #17
0
        public IHttpActionResult PostEmployee(EmployeeDetail data)
        {
            var employee = new Employee();
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }
            try
            {

                employee.Name = data.EmpName;
                employee.Salary = data.Salary;
                employee.TaxAmount = GetTaxAmount(data.Salary);
                employee.Address = data.Address;
                employee.EmailId = data.EmailId;
                employee.DateOfBirth = data.DateOfBirth;
                employee.Gender = data.Gender;
                employee.PinCode = data.PinCode;
                employeeRepository.AddEmployee(employee);
            }
            catch (Exception)
            {
                throw;
            }

            return Ok(employee);
        }
コード例 #18
0
        public EmployeeDetailViewModel(EmployeeDetail employeeDetailOpen, tblOrder orderPar)
        {
            employeeDetail = employeeDetailOpen;
            order          = orderPar;

            service = new PizzeriaService();
            if (orderPar.OrderStatus == "W")
            {
                ViewApprove = Visibility.Visible;
                ViewDelete  = Visibility.Hidden;
                Status      = "Status: Waiting";
            }
            else if (orderPar.OrderStatus == "A")
            {
                ViewDelete  = Visibility.Visible;
                ViewApprove = Visibility.Hidden;
                Status      = "Status: Approved";
            }
            else
            {
                ViewDelete  = Visibility.Visible;
                ViewApprove = Visibility.Hidden;
                Status      = "Status: Refused";
            }
            PizzaOrders = service.GetPizzaOrdersByOrderID(orderPar.ID);
        }
コード例 #19
0
        public IHttpActionResult PutEmployeeMaster(EmployeeDetail employee)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            try
            {
                Employee data = new Employee();
                data.Address = employee.Address;
                data.DateOfBirth = employee.DateOfBirth;
                data.EmailId = employee.EmailId;
                data.Gender = employee.Gender;
                data.Id = employee.EmpId;
                data.Name = employee.EmpName;
                data.Salary = employee.Salary;
                data.TaxAmount = GetTaxAmount(employee.Salary);
                data.PinCode = employee.PinCode;
                employeeRepository.UpdateEmployee(data);
            }
            catch (Exception)
            {
                throw;
            }
            return Ok(employee);
        }
コード例 #20
0
        public async Task <IActionResult> PutEmployeeDetail([FromRoute] int id, [FromBody] EmployeeDetail employeeDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != employeeDetail.EId)
            {
                return(BadRequest());
            }

            try
            {
                await _handler.PutEmployeeDetailAsync(id, employeeDetail);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!(_handler.EmployeeDetailExists(id)))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Ok());
        }
コード例 #21
0
        public async Task <ApiResponse> Handle(AddNewEmployeeCommand request, CancellationToken cancellationToken)
        {
            ApiResponse response = new ApiResponse();

            try
            {
                EmployeeDetail obj = _mapper.Map <EmployeeDetail>(request);
                obj.IsDeleted = false;
                await _dbContext.EmployeeDetail.AddAsync(obj);

                await _dbContext.SaveChangesAsync();

                OfficeDetail OfficeDetail = await _dbContext.OfficeDetail.FirstOrDefaultAsync(x => x.OfficeId == request.OfficeId && x.IsDeleted == false);

                EmployeeDetail emp = await _dbContext.EmployeeDetail.FirstOrDefaultAsync(x => x.IsDeleted == false && x.EmployeeID == obj.EmployeeID);

                emp.EmployeeCode = "E" + obj.EmployeeID;
                _dbContext.EmployeeDetail.Update(emp);
                await _dbContext.SaveChangesAsync();

                EmployeeProfessionalDetailModel empprofessional = new EmployeeProfessionalDetailModel
                {
                    EmployeeId     = obj.EmployeeID,
                    EmployeeTypeId = request.EmployeeTypeId,
                    OfficeId       = request.OfficeId,
                    CreatedById    = request.CreatedById,
                    CreatedDate    = request.CreatedDate,
                    IsDeleted      = request.IsDeleted,
                    ProfessionId   = request.ProfessionId,
                    TinNumber      = request.TinNumber
                };
                EmployeeProfessionalDetail obj1 = _mapper.Map <EmployeeProfessionalDetail>(empprofessional);
                await _dbContext.EmployeeProfessionalDetail.AddAsync(obj1);

                await _dbContext.SaveChangesAsync();

                UserDetails user = await _dbContext.UserDetails.FirstOrDefaultAsync(x => x.AspNetUserId == request.CreatedById && x.IsDeleted == false);

                LoggerDetailsModel loggerObj = new LoggerDetailsModel();
                loggerObj.NotificationId = (int)Common.Enums.LoggerEnum.EmployeeCreated;
                loggerObj.IsRead         = false;
                loggerObj.UserName       = user.FirstName + " " + user.LastName;
                loggerObj.UserId         = request.CreatedById;
                loggerObj.LoggedDetail   = "Employee " + obj.EmployeeName + " Created";
                loggerObj.CreatedDate    = request.CreatedDate;

                response.LoggerDetailsModel = loggerObj;

                await _dbContext.SaveChangesAsync();

                response.StatusCode = StaticResource.successStatusCode;
                response.Message    = "Success";
            }
            catch (Exception ex)
            {
                response.StatusCode = StaticResource.failStatusCode;
                response.Message    = StaticResource.SomethingWrong + ex.Message;
            }
            return(response);
        }
コード例 #22
0
        public EmployeeDetail Get(int id)
        {
            var entity = GetAsNoTracking(p => p.Active == true && p.Id == id).FirstOrDefault();
            var result = new EmployeeDetail(entity, mapper);

            return(result);
        }
コード例 #23
0
        public ActionResult onclick(int id)
        {
            EmployeeDetail ed = new EmployeeDetail();
            DataTable      dt = new DataTable();

            using (con)
            {
                try
                {
                    con.Open();
                    SqlCommand cmd = new SqlCommand("onclick", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("Empid", id);

                    SqlDataAdapter sda = new SqlDataAdapter(cmd);
                    cmd.ExecuteNonQuery();
                    sda.Fill(dt);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
            return(View(dt));
        }
コード例 #24
0
        public async Task <ActionResult <EmployeeDetail> > PostEmployeeDetail(EmployeeDetail employeeDetail)
        {
            _context.EmployeeDetails.Add(employeeDetail);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetEmployeeDetail", new { id = employeeDetail.id }, employeeDetail));
        }
コード例 #25
0
        public ActionResult CreateEmployeeDetail(EmployeeDetail ed)
        {
            DataTable dt = new DataTable();

            using (con)
            {
                try
                {
                    con.Open();
                    SqlCommand cmd = new SqlCommand("SP_CreateEmpDetail", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    SqlDataAdapter sda = new SqlDataAdapter(cmd);

                    cmd.Parameters.AddWithValue("Empid", ed.Empid);
                    cmd.Parameters.AddWithValue("@DateOfBirth", ed.DateOfBirth);
                    cmd.Parameters.AddWithValue("@DateOfJoining", ed.DateOfJoining);
                    cmd.Parameters.AddWithValue("@Designation", ed.Designation);
                    cmd.Parameters.AddWithValue("@Degree", ed.Degree);
                    cmd.Parameters.AddWithValue("@PassOutYear", ed.PassOutYear);


                    cmd.ExecuteNonQuery();
                    sda.Fill(dt);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
            return(RedirectToAction("ListEmployeeDetails"));
        }
コード例 #26
0
        public IHttpActionResult PostEmployeeDetail(EmployeeDetail employeeDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.EmployeeDetails.Add(employeeDetail);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (EmployeeDetailExists(employeeDetail.Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = employeeDetail.Id }, employeeDetail));
        }
コード例 #27
0
        public EmployeeDetail GetEmployeeDetailById(int employeeId)
        {
            EmployeeDetail employee = null;

            using (var connection = new SqlConnection(ConnectionString))
            {
                if (connection.State == ConnectionState.Closed)
                {
                    connection.Open();
                }

                var sqlParameters = new List <SqlParameter>()
                {
                    new SqlParameter("@empId", employeeId)
                };
                using (var command = new SqlCommand())
                {
                    CreateProcedureCommand(command, "usp_GetEmployeeDetail", connection, sqlParameters.ToArray());
                    using (var rdr = command.ExecuteReader())
                    {
                        while (rdr.Read())
                        {
                            employee            = new EmployeeDetail();
                            employee.EmployeeId = Convert.ToInt32(rdr["EmployeeId"]);
                            employee.Name       = Convert.ToString(rdr["Name"]);
                            employee.Address    = Convert.ToString(rdr["Address"]);
                            employee.Salary     = (!string.IsNullOrEmpty(Convert.ToString(rdr["Salary"]))) ? Convert.ToInt32(rdr["Salary"]) : 0;
                            employee.DeptName   = Convert.ToString(rdr["DeptName"]);
                            employee.IsActive   = Convert.ToBoolean(rdr["IsActive"]);
                        }
                    }
                }
                return(employee);
            }
        }
コード例 #28
0
        public EmployeeDetail GetEmployeeById(int id)
        {
            var entity = _context.Employees.Find(id);

            if (entity == null)
            {
                return(null);
            }

            var model = new EmployeeDetail
            {
                PersonID        = entity.PersonID,
                EmployeeID      = entity.EmployeeID,
                FirstName       = entity.FirstName,
                LastName        = entity.LastName,
                JobTitle        = entity.JobTitle,
                StreetAddress   = entity.StreetAddress,
                City            = entity.City,
                State           = entity.State,
                ZipCode         = entity.ZipCode,
                PhoneNumber     = entity.PhoneNumber,
                Email           = entity.Email,
                Pets            = entity.Pets,
                HireDate        = entity.HireDate,
                TerminationDate = entity.TerminationDate,
            };

            return(model);
        }
コード例 #29
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,EmailAddress")] EmployeeDetail employeeDetail)
        {
            if (id != employeeDetail.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(employeeDetail);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EmployeeDetailExists(employeeDetail.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(employeeDetail));
        }
コード例 #30
0
        public ActionResult Edit(EmployeeDetailsVM employeeDetailsVM)
        {
            try
            {
                EmployeeDetail emp = db.EmployeeInfo.Find(employeeDetailsVM.EmployeeId);

                emp.Address     = employeeDetailsVM.Address;
                emp.Number      = employeeDetailsVM.Number;
                emp.Name        = employeeDetailsVM.Name;
                emp.UpdatedBy   = 1;
                emp.UpdatedDate = DateTime.Now;

                db.SaveChanges();

                var routeValues = new RouteValueDictionary {
                    { "Message", "Success" }
                };
                return(RedirectToAction("Index", "EmployeeDetail", routeValues));
            }
            catch (Exception ex)
            {
                var routeValues = new RouteValueDictionary {
                    { "Message", "Error" }
                };
                return(RedirectToAction("Index", "EmployeeDetail", routeValues));
            }
        }
コード例 #31
0
        //GET: Employee/Details
        public ActionResult Details(int id)
        {
            EmployeeService service = CreateEmployeeService();
            EmployeeDetail  model   = service.GetEmployeeById(id);

            return(View(model));
        }
コード例 #32
0
        //mmddyyyy format
        private Summary TargetProcessSummary(string strDate)
        {
            Summary summary = null;
            try
            {
                lock (_doTPWorkSync)
                {
                    DateTime requestedDate = strDate.StringToDateTime();
                    DateTime previousMonday = requestedDate.StartOfWeek(DayOfWeek.Monday);
                    previousMonday = previousMonday.AddDays(-1); //hack
                    requestedDate = requestedDate.AddDays(1); // & hack to get the number right (as they should be)

                    //Step 1 : Collect all emails
                    summary = new Summary(strDate.StringToDateTime());
                    var webClient = new WebClient();
                    //webClient.Headers.Add("Authorization", "Basic YXR1bGM6dGVzdGluZw=="); //atul's key
                    webClient.Headers.Add("Authorization", "Basic a2V2aW5tOlJVQ3Jhenky"); //kevin's key
                    JavaScriptSerializer jss = new JavaScriptSerializer();
                    jss.RegisterConverters(new JavaScriptConverter[] { new DynamicJsonConverter() });

                    var nextLink = "http://tp.yaharasoftware.com/api/v1/Users?format=json";

                    while (nextLink != null)
                    {
                        Stream data = webClient.OpenRead(nextLink);
                        StreamReader reader = new StreamReader(data);
                        string json = reader.ReadToEnd();
                        //Debug.WriteLine(json);
                        data.Close();
                        reader.Close();

                        dynamic tpEntry = jss.Deserialize(json, typeof(object)) as dynamic;
                        int count = tpEntry.Items.Count;
                        for (int i = 0; i < count; i++)
                        {
                            try
                            {
                                string email = tpEntry.Items[i]["Email"].ToLower();
                                if (!email.Contains("yahara") || tpEntry.Items[i]["IsActive"] == false)
                                    continue;

                                EmployeeDetail ed = new EmployeeDetail();
                                ed.Id = tpEntry.Items[i]["Id"];
                                ed.Name = tpEntry.Items[i]["FirstName"] + " " + tpEntry.Items[i]["LastName"];
                                ed.Email = tpEntry.Items[i]["Email"];
                                summary.ListOfItems.Add(ed);
                            }
                            catch
                            {
                                //ignore and move on
                            }
                        }
                        try
                        {
                            if (tpEntry.Next != null)
                                nextLink = tpEntry.Next;
                            else
                                nextLink = null;
                        }
                        catch (KeyNotFoundException)
                        {
                            nextLink = null;
                        }
                    }

                    //Step 2 : Collect all times for this week
                    //var nextTimeLink = "http://tp.yaharasoftware.com/api/v1/Times?format=json&take=1000&where=(Date%20gt%20'2012-04-16')%20and%20(Date%20lt%20'2012-04-19')";
                    var nextTimeLink = "http://tp.yaharasoftware.com/api/v1/Times?format=json&take=1000&where=(Date%20gt%20'"
                                        + previousMonday.ToString("yyyy-MM-dd")
                                        + "')%20and%20(Date%20lt%20'"
                                        + requestedDate.ToString("yyyy-MM-dd")
                                        + "')";

                    while (nextTimeLink != null)
                    {
                        Stream data = webClient.OpenRead(nextTimeLink);
                        StreamReader reader = new StreamReader(data);
                        string json = reader.ReadToEnd();
                        //Debug.WriteLine(json);
                        data.Close();
                        reader.Close();

                        dynamic tpEntry = jss.Deserialize(json, typeof(object)) as dynamic;
                        int count = tpEntry.Items.Count;
                        for (int i = 0; i < count; i++)
                        {
                            try
                            {
                                int Id = tpEntry.Items[i]["User"]["Id"];
                                var ed = (from l in summary.ListOfItems where l.Id == Id select l).FirstOrDefault();
                                if (ed == null)
                                    continue;

                                DateTime dateTimeSpentOn = tpEntry.Items[i]["Date"];
                                decimal timeSpent = tpEntry.Items[i]["Spent"];

                                if ((requestedDate.GetEndOfDay().CompareTo(dateTimeSpentOn) >= 0) && (previousMonday.Date.CompareTo(dateTimeSpentOn) <= 0))
                                {
                                    (from l in summary.ListOfItems where l.Id == Id select l).First().TotalHoursLogged += timeSpent;
                                }
                            }
                            catch
                            {
                                //ignore and move on
                            }
                        }
                        try
                        {
                            if (tpEntry.Next != null)
                                nextTimeLink = tpEntry.Next;
                            else
                                nextTimeLink = null;
                        }
                        catch (KeyNotFoundException)
                        {
                            nextTimeLink = null;
                        }
                    }

                    EmployeeDetailComparer dc = new EmployeeDetailComparer();
                    summary.ListOfItems.Sort(dc);

                }
            }
            catch
            {
                ;//Exception swallowing technology
            }
            return summary;
        }
コード例 #33
0
        //mmddyyyy format
        private Summary WebShadowSummary(string strDate)
        {
            Summary summary = null;
            try
            {
                lock (_doTPWorkSync)
                {
                    DateTime requestedDate = strDate.StringToDateTime();
                    DateTime previousMonday = requestedDate.StartOfWeek(DayOfWeek.Monday);

                    ForecastSummary fs = GetForecast(previousMonday.DateTimeToString(), requestedDate.DateTimeToString());

                    summary = new Summary(strDate.StringToDateTime());
                    summary.ListOfItems = new List<EmployeeDetail>(fs.Resources.Count);

                    foreach (ResourceSummary rs in fs.Resources)
                    {
                        EmployeeDetail ed = new EmployeeDetail();
                        ed.TotalHoursLogged = (decimal)rs.TotalHoursRecorded;
                        ed.Name = rs.Resource.FirstName + " " + rs.Resource.LastName;
                        summary.ListOfItems.Add(ed);
                    }

                    EmployeeDetailComparer dc = new EmployeeDetailComparer();
                    summary.ListOfItems.Sort(dc);
                }
            }
            catch
            {
                ;//Exception Swallowing Technology
            }
            return summary;
        }