示例#1
0
        public void InsertStaff_HasNewPhoneNumber_InsertToListVM()
        {
            var newStaff = new staff()
            {
                id               = 4,
                full_name        = "nv4",
                date_of_birth    = new DateTime(1999, 1, 3),
                phone_number     = "1945664870",
                salary           = 4500000,
                is_still_working = true,
                permission_id    = 1,
            };

            _sut.InsertStaff(newStaff);

            var mockUpdatedStaffVMs = _sut.GetStaffList();

            StaffViewModel stubStaffVM = new StaffViewModel()
            {
                Id           = 4,
                DateOfBirth  = new DateTime(1999, 1, 3),
                FullName     = "nv4",
                PhoneNumber  = "1945664870",
                Salary       = 4500000,
                PositionName = "QUAN LY"
            };

            mockUpdatedStaffVMs.Should().ContainEquivalentOf(stubStaffVM);
        }
示例#2
0
        public ActionResult CreateStaff(Staff staff)
        {
            var repo      = new StaffRepository();
            var repoStaff = repo.InsertStaff(staff);

            return(View(repoStaff));
        }
        public ActionResult AddStaff(StaffModel staffModel)
        {
            try
            {
                if (staffModel.FileName.ContentLength > 0)
                {
                    if (ModelState.IsValid)
                    {
                        string _PhotoName = Path.GetFileName(staffModel.FileName.FileName).Replace(" ", "");
                        string _path      = Path.Combine(Server.MapPath("~/UploadedFiles"), _PhotoName);
                        staffModel.FileName.SaveAs(_path);

                        StaffTable staffTable = new StaffTable()
                        {
                            ID            = staffModel.ID,
                            ACDetails     = staffModel.ACDetails,
                            DateOfBirth   = staffModel.DateOfBirth,
                            DateOfJoin    = staffModel.DateOfJoin,
                            Designation   = staffModel.Designation,
                            Salary        = staffModel.Salary,
                            Experience    = staffModel.Experience,
                            SchoolMatric  = staffModel.SchoolMatric,
                            Name          = staffModel.Name,
                            Staff         = staffModel.Staff,
                            Qualification = staffModel.Qualification,
                            PhotoGraph    = "/UploadedFiles/" + _PhotoName
                        };

                        if (staffTable.ID > 0)
                        {
                            staffRepository.UpdateStaff(staffTable);
                        }
                        else
                        {
                            staffRepository.InsertStaff(staffTable);
                        }
                    }
                }
                else
                {
                    return(View(staffModel));
                }
                return(RedirectToAction("Technical"));
            }
            catch (Exception)
            {
                return(View(staffModel));
            }
        }
示例#4
0
        public ActionResult StaffCreate(StaffModel staffModel)
        {
            try
            {
                Staff staff = new Staff
                {
                    ID               = staffModel.ID,
                    AadharNumber     = staffModel.AadharNumber,
                    DateOfBirth      = staffModel.DateOfBirth,
                    DateOfJoin       = staffModel.DateOfJoin,
                    Salary           = staffModel.Salary,
                    StaffName        = staffModel.StaffName,
                    StaffType        = staffModel.StaffType,
                    Subject          = staffModel.Subject,
                    SubjectNumFirst  = staffModel.SubjectNumFirst,
                    SubjectNumSecond = staffModel.SubjectNumSecond,
                    TeachSubFirst    = staffModel.TeachSubFirst,
                    TeachSubSecond   = staffModel.TeachSubSecond,
                    Designation      = staffModel.Designation,
                    Experience       = staffModel.Experience,
                    FatherName       = staffModel.FatherName,
                    PanNumber        = staffModel.PanNumber
                };
                if (ModelState.IsValid)
                {
                    if (staff.ID > 0)
                    {
                        staffRepository.InsertStaff(staff);
                    }
                    else
                    {
                        staffRepository.UpdateStaff(staff);
                    }
                }
                else
                {
                    return(View(staffModel));
                }


                return(RedirectToAction("TeachingSatff"));
            }
            catch (Exception)
            {
                return(View(staffModel));
            }
        }
示例#5
0
        public StaffModel RegisterTranslator(StaffModel model)
        {
            try
            {
                IUnitOfWork      ouw     = new UnitOfWork();
                IStaffRepository rep     = new StaffRepository(ouw);
                IStaffService    service = new StaffService(rep);
                IStaffBankAccountInfoRepository        bankrep     = new StaffBankAccountInfoRepository(ouw);
                IStaffBankAccountInfoService           bankservice = new StaffBankAccountInfoService(bankrep);
                IStaffSoftwareRepository               _staffsoftwareRepository = new StaffSoftwareSkillRepository(ouw);
                IStaffProfessioanlSpecialityRepository _spRepository            = new StaffProfessioanlSpecialityRepository(ouw);
                IStaffCurrentStateRepository           _cstateRepository        = new StaffCurrentStateRepository(ouw);

                if (model.ID == Guid.Empty)
                {
                    model.ID               = Guid.NewGuid();
                    model.Password         = Utility.MD5(model.Password);
                    model.CreatedDate      = DateTime.Now;
                    model.RegistrationDate = DateTime.Now;
                    Utility.SetDynamicPropertyValue(model, model.CurrentCulture);
                    var map = Mapper.Map <StaffModel, Staff>(model);
                    rep.InsertStaff(map);

                    //model.Staffbank.ID = model.ID;
                    if (model.Staffbank.ID == Guid.Empty)
                    {
                        model.Staffbank.ID      = Guid.NewGuid();
                        model.Staffbank.StaffID = model.ID;
                        //
                        model.Staffbank.CurrentCulture = model.CurrentCulture;

                        Utility.SetDynamicPropertyValue(model.Staffbank, model.CurrentCulture);
                        var bnk = Mapper.Map <StaffBankAccountInfoModel, Staff_BankAccountInfo>(model.Staffbank);
                        bankrep.InsertStaffBankAccountInfo(bnk);
                    }
                }
                else
                {
                    Utility.SetDynamicPropertyValue(model, model.CurrentCulture);
                    var map = Mapper.Map <StaffModel, Staff>(model);
                    var bnk = Mapper.Map <StaffBankAccountInfoModel, Staff_BankAccountInfo>(model.Staffbank);
                    rep.UpdateStaff(map);
                    bankrep.UpdateStaffBankAccountInfo(bnk);
                }

                foreach (StaffSoftwareSkillModel staff in model.staffsoft)
                {
                    staff.StaffID = model.ID;
                    var software = Mapper.Map <StaffSoftwareSkillModel, Staff_SoftwareSkill>(staff);
                    if (staff.ID == Guid.Empty)
                    {
                        software.CreatedDate = DateTime.Now;
                        software.ID          = Guid.NewGuid();

                        _staffsoftwareRepository.InsertStaffSkill(software);
                    }
                    else
                    {
                        software.UpdatedDate = DateTime.Now;
                        software.UpdatedBy   = staff.UpdatedBy;
                        _staffsoftwareRepository.UpdateStaffSkill(software);
                    }
                }
                foreach (StaffProfesionalSpecialityModel professional in model.StaffProfessional)
                {
                    professional.StaffID = model.ID;
                    var staffspecial = Mapper.Map <StaffProfesionalSpecialityModel, Staff_ProfessionalSpeciality>(professional);

                    if (professional.ID > 0)
                    {
                        _spRepository.UpdateStaffProfessinalSpeciality(staffspecial);
                    }
                    else
                    {
                        _spRepository.InsertStaffProfessinalSpeciality(staffspecial);
                    }
                }
                foreach (StaffCurrentStateModel state in model.StaffCurrentState)
                {
                    state.StaffID = model.ID;
                    var staffcurrentstate = Mapper.Map <StaffCurrentStateModel, Staff_CurrentStates>(state);

                    if (state.ID > 0)
                    {
                        _cstateRepository.UpdateStaffCurrentState(staffcurrentstate);
                    }
                    else
                    {
                        _cstateRepository.InsertStaffCurrentState(staffcurrentstate);
                    }
                }
            }
            catch (Exception ex)
            {
                model = null;
                //isRegistered = false;
                //IErrorLogService errorLog = new ErrorLogService();
                string message = ex.InnerException != null ? ex.InnerException.InnerException.Message : ex.Message;
                //errorLog.SetErrorLog(model.CurrentUserID, "TranslatorRegistrationFromTranspro", message);
                throw new Exception(ex.Message);
            }
            return(model);
        }
示例#6
0
 // POST: api/Staff
 /// <summary>
 /// Add new staff
 /// </summary>
 /// <param name="theStaff"></param>
 /// <returns>bool</returns>
 public bool Post([FromBody] StaffModel theStaff)
 {
     return(_staffRepository.InsertStaff(theStaff));
 }