コード例 #1
0
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var labour = await _dataContext.Labours
                         .Include(p => p.Employee)
                         .Include(p => p.LabourType)
                         .FirstOrDefaultAsync(p => p.Id == id.Value);

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

            var model = new LabourViewModel
            {
                Start        = labour.Start,
                Id           = labour.Id,
                ImageUrl     = labour.ImageUrl,
                Name         = labour.Name,
                EmployeeId   = labour.Employee.Id,
                LabourTypeId = labour.LabourType.Id,
                LabourTypes  = _combosHelper.GetComboLabourTypes(),
                Activity     = labour.Activity,
                Remarks      = labour.Remarks
            };

            return(View(model));
        }
コード例 #2
0
        public HttpResponseMessage SaveLabour(HttpRequestMessage request, LabourViewModel savelabour)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;
                if (!ModelState.IsValid)
                {
                    response = request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
                }
                else
                {
                    //start of saving to master emp table
                    var codeFormat = _settingsRepository.GetAll().Where(t => t.tenant_id == savelabour.tenant_id).FirstOrDefault();
                    var exsistingEmployees = _EmployeeRepository.GetAll().Where(e => e.tenant_id == savelabour.tenant_id);

                    tbl_employee newEmployeeMaster = new tbl_employee();
                    int empCount = exsistingEmployees.Count();

                    if (empCount <= 0)
                    {
                        newEmployeeMaster.emp_code = codeFormat.emp_code;
                        newEmployeeMaster.code_seperation = codeFormat.code_seperation;
                        newEmployeeMaster.emp_num = codeFormat.emp_num;
                    }
                    else
                    {
                        var lastERec = _EmployeeRepository.GetAll().Where(e => e.tenant_id == savelabour.tenant_id).OrderByDescending(e => e.id).First();
                        // var lastERec = _EmployeeRepository.GetSingle(empCount);
                        newEmployeeMaster.emp_code = lastERec.emp_code;
                        newEmployeeMaster.code_seperation = lastERec.code_seperation;
                        newEmployeeMaster.emp_num = lastERec.emp_num + 1;
                    }

                    newEmployeeMaster.tenant_id = savelabour.tenant_id;
                    newEmployeeMaster.project_id = savelabour.project_id;
                    newEmployeeMaster.Designation = "Labour";
                    newEmployeeMaster.emp_name = savelabour.name;
                    newEmployeeMaster.date_created = DateTime.Now;
                    newEmployeeMaster.CreatedBy = "Admin";

                    _EmployeeRepository.Add(newEmployeeMaster);
                    //_unitOfWork.Commit();


                    //end of saving to master emp table.



                    tbl_labour newlabour = new tbl_labour();
                    newlabour.master_emp_id = _EmployeeRepository.GetAll().Count() + 1;
                    newlabour.AddLabour(savelabour);
                    _labourRepository.Add(newlabour);
                    _unitOfWork.Commit();
                    response = request.CreateResponse <LabourViewModel>(HttpStatusCode.Created, savelabour);
                }
                return response;
            }));
        }
コード例 #3
0
        public async Task <IActionResult> Edit(LabourViewModel model)
        {
            if (ModelState.IsValid)
            {
                var path = model.ImageUrl;

                if (model.ImageFile != null && model.ImageFile.Length > 0)
                {
                    var guid = Guid.NewGuid().ToString();
                    var file = $"{guid}.jpg";

                    path = Path.Combine(
                        Directory.GetCurrentDirectory(),
                        "wwwroot\\images\\Labours",
                        file);

                    using (var stream = new FileStream(path, FileMode.Create))
                    {
                        await model.ImageFile.CopyToAsync(stream);
                    }

                    path = $"~/images/Labours/{file}";
                }

                var labour = new Labour
                {
                    Start      = model.Start,
                    Id         = model.Id,
                    ImageUrl   = path,
                    Name       = model.Name,
                    Employee   = await _dataContext.Employees.FindAsync(model.EmployeeId),
                    LabourType = await _dataContext.LabourTypes.FindAsync(model.LabourTypeId),
                    Activity   = model.Activity,
                    Remarks    = model.Remarks
                };

                _dataContext.Labours.Update(labour);
                await _dataContext.SaveChangesAsync();

                return(RedirectToAction(nameof(MyLabours)));
            }

            model.LabourTypes = _combosHelper.GetComboLabourTypes();
            return(View(model));
        }
コード例 #4
0
 public LabourPaymentDetail()
 {
     InitializeComponent();
     _viewModel  = new LabourViewModel(SiteDetail.SiteId);
     DataContext = _viewModel;
     _viewModel.MessageBoxEvent += (msg) =>
     {
         var result = MessageBox.Show(msg, "Delete", MessageBoxButton.YesNo);
         if (result == MessageBoxResult.Yes)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     };
 }
コード例 #5
0
        public async Task <Labour> ToLabourAsync(LabourViewModel model, string path, bool isNew)
        {
            var labour = new Labour
            {
                Agendas    = model.Agendas,
                Start      = model.Start,
                Reports    = model.Reports,
                Id         = isNew ? 0 : model.Id,
                ImageUrl   = path,
                Name       = model.Name,
                Employee   = await _dataContext.Employees.FindAsync(model.EmployeeId),
                LabourType = await _dataContext.LabourTypes.FindAsync(model.LabourTypeId),
                Activity   = model.Activity,
                Remarks    = model.Remarks
            };

            return(labour);
        }
コード例 #6
0
        public async Task <IActionResult> Create()
        {
            var employee = await _dataContext.Employees
                           .FirstOrDefaultAsync(o => o.User.Email.ToLower().Equals(User.Identity.Name.ToLower()));

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

            var model = new LabourViewModel
            {
                Start       = DateTime.Now,
                LabourTypes = _combosHelper.GetComboLabourTypes(),
                EmployeeId  = employee.Id
            };

            return(View(model));
        }
コード例 #7
0
        public async Task <IActionResult> EditLabour(LabourViewModel model)
        {
            if (ModelState.IsValid)
            {
                var path = model.ImageUrl;

                if (model.ImageFile != null)
                {
                    path = await _imageHelper.UploadImageAsync(model.ImageFile);
                }

                var labour = await _converterHelper.ToLabourAsync(model, path, false);

                _dataContext.Labours.Update(labour);
                await _dataContext.SaveChangesAsync();

                return(RedirectToAction($"Details/{model.EmployeeId}"));
            }

            model.LabourTypes = _combosHelper.GetComboLabourTypes();
            return(View(model));
        }
コード例 #8
0
        public async Task <IActionResult> AddLabour(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var employee = await _dataContext.Employees.FindAsync(id.Value);

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

            var model = new LabourViewModel
            {
                Start       = DateTime.Today,
                EmployeeId  = employee.Id,
                LabourTypes = _combosHelper.GetComboLabourTypes()
            };

            return(View(model));
        }
コード例 #9
0
        public HttpResponseMessage UpdateLabour(HttpRequestMessage request, LabourViewModel labour)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;

                if (!ModelState.IsValid)
                {
                    response = request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
                }
                else
                {
                    var existinglabour = _labourRepository.GetSingle(labour.id);
                    existinglabour.subcontractor_id = labour.subcontractor_id;
                    existinglabour.name = labour.name;
                    existinglabour.fathers_name = labour.fathers_name;
                    existinglabour.gender = labour.gender;
                    existinglabour.age = labour.age;
                    existinglabour.blood_group = labour.blood_group;
                    existinglabour.mother_tongue = labour.mother_tongue;

                    existinglabour.current_street = labour.current_street;
                    existinglabour.current_state = labour.current_state;
                    existinglabour.current_country = labour.current_country;
                    existinglabour.current_city = labour.current_city;
                    existinglabour.current_zip = labour.current_zip;
                    existinglabour.current_contact_number = labour.current_contact_number;

                    existinglabour.permanent_street = labour.permanent_street;
                    existinglabour.permanent_country = labour.permanent_country;
                    existinglabour.permanent_state = labour.permanent_state;
                    existinglabour.permanent_city = labour.permanent_city;
                    existinglabour.permanent_zip = labour.permanent_zip;
                    existinglabour.permanent_contact_number = labour.permanent_contact_number;

                    existinglabour.contact_person_name = labour.contact_person_name;
                    existinglabour.contact_person_relationship_id = labour.contact_person_relationship_id;
                    existinglabour.contact_person_street = labour.contact_person_street;
                    existinglabour.contact_person_country = labour.contact_person_country;
                    existinglabour.contact_person_state = labour.contact_person_state;
                    existinglabour.contact_person_city = labour.contact_person_city;
                    existinglabour.contact_person_zip = labour.contact_person_zip;
                    existinglabour.contact_person_contact_number = labour.contact_person_contact_number;

                    existinglabour.bank_name = labour.bank_name;
                    existinglabour.bank_account_no = labour.bank_account_no;
                    existinglabour.bank_branch = labour.bank_branch;
                    existinglabour.ifsc = labour.ifsc;
                    existinglabour.pan = labour.pan;
                    existinglabour.aadhar = labour.aadhar;
                    existinglabour.epf_no = labour.epf_no;
                    existinglabour.esi_no = labour.esi_no;

                    existinglabour.labour_photo = labour.labour_photo;
                    existinglabour.labour_photo_file_type = labour.labour_photo_file_type;
                    existinglabour.labour_filename = labour.labour_filename;

                    existinglabour.check_aadhar = labour.check_aadhar;
                    existinglabour.aadhar_encode = labour.aadhar_encode;
                    existinglabour.aadhar_encode_file_type = labour.aadhar_encode_file_type;
                    existinglabour.aadhar_filename = labour.aadhar_filename;

                    existinglabour.check_bank = labour.check_bank;
                    existinglabour.bank_encode = labour.bank_encode;
                    existinglabour.bank_encode_file_type = labour.bank_encode_file_type;
                    existinglabour.bank_filename = labour.bank_filename;

                    existinglabour.check_medical_certificate = labour.check_medical_certificate;
                    existinglabour.medical_certificate_encode = labour.medical_certificate_encode;
                    existinglabour.medical_certificate_encode_file_type = labour.medical_certificate_encode_file_type;
                    existinglabour.medical_filename = labour.medical_filename;

                    existinglabour.check_eye_certificate = labour.check_eye_certificate;
                    existinglabour.eye_certificate_encode = labour.eye_certificate_encode;
                    existinglabour.eye_certificate_encode_file_type = labour.eye_certificate_encode_file_type;
                    existinglabour.eye_certificate_filenmae = labour.eye_certificate_filenmae;

                    existinglabour.modified_date = DateTime.Now;
                    existinglabour.modified_by = labour.modified_by;

                    _labourRepository.Edit(existinglabour);

                    _unitOfWork.Commit();

                    response = request.CreateResponse(HttpStatusCode.OK);
                }

                return response;
            }));
        }
コード例 #10
0
        public static void AddLabour(this tbl_labour labour, LabourViewModel labourVm)
        {
            labour.tenant_id        = labourVm.tenant_id;
            labour.project_id       = labourVm.project_id;
            labour.subcontractor_id = labourVm.subcontractor_id;
            labour.name             = labourVm.name;
            labour.fathers_name     = labourVm.fathers_name;
            labour.gender           = labourVm.gender;
            labour.age           = labourVm.age;
            labour.blood_group   = labourVm.blood_group;
            labour.mother_tongue = labourVm.mother_tongue;

            labour.current_street         = labourVm.current_street;
            labour.current_state          = labourVm.current_state;
            labour.current_country        = labourVm.current_country;
            labour.current_city           = labourVm.current_city;
            labour.current_zip            = labourVm.current_zip;
            labour.current_contact_number = labourVm.current_contact_number;

            labour.permanent_street         = labourVm.permanent_street;
            labour.permanent_country        = labourVm.permanent_country;
            labour.permanent_state          = labourVm.permanent_state;
            labour.permanent_city           = labourVm.permanent_city;
            labour.permanent_zip            = labourVm.permanent_zip;
            labour.permanent_contact_number = labourVm.permanent_contact_number;

            labour.contact_person_name            = labourVm.contact_person_name;
            labour.contact_person_relationship_id = labourVm.contact_person_relationship_id;
            labour.contact_person_street          = labourVm.contact_person_street;
            labour.contact_person_country         = labourVm.contact_person_country;
            labour.contact_person_state           = labourVm.contact_person_state;
            labour.contact_person_city            = labourVm.contact_person_city;
            labour.contact_person_zip             = labourVm.contact_person_zip;
            labour.contact_person_contact_number  = labourVm.contact_person_contact_number;

            labour.bank_name       = labourVm.bank_name;
            labour.bank_account_no = labourVm.bank_account_no;
            labour.bank_branch     = labourVm.bank_branch;
            labour.ifsc            = labourVm.ifsc;
            labour.pan             = labourVm.pan;
            labour.aadhar          = labourVm.aadhar;
            labour.epf_no          = labourVm.epf_no;
            labour.esi_no          = labourVm.esi_no;

            labour.labour_photo           = labourVm.labour_photo;
            labour.labour_photo_file_type = labourVm.labour_photo_file_type;
            labour.labour_filename        = labourVm.labour_filename;

            labour.check_aadhar            = labourVm.check_aadhar;
            labour.aadhar_encode           = labourVm.aadhar_encode;
            labour.aadhar_encode_file_type = labourVm.aadhar_encode_file_type;
            labour.aadhar_filename         = labourVm.aadhar_filename;

            labour.check_bank            = labourVm.check_bank;
            labour.bank_encode           = labourVm.bank_encode;
            labour.bank_encode_file_type = labourVm.bank_encode_file_type;
            labour.bank_filename         = labourVm.bank_filename;

            labour.check_medical_certificate            = labourVm.check_medical_certificate;
            labour.medical_certificate_encode           = labourVm.medical_certificate_encode;
            labour.medical_certificate_encode_file_type = labourVm.medical_certificate_encode_file_type;
            labour.medical_filename = labourVm.medical_filename;

            labour.check_eye_certificate            = labourVm.check_eye_certificate;
            labour.eye_certificate_encode           = labourVm.eye_certificate_encode;
            labour.eye_certificate_encode_file_type = labourVm.eye_certificate_encode_file_type;
            labour.eye_certificate_filenmae         = labourVm.eye_certificate_filenmae;

            labour.created_date  = DateTime.Now;
            labour.created_by    = labourVm.created_by;
            labour.modified_date = DateTime.Now;
            labour.modified_by   = labourVm.modified_by;
        }