Ejemplo n.º 1
0
        public static List <StaffViewModel> GetAll()
        {
            StaffViewModel        mappedStaff = new StaffViewModel();
            List <StaffViewModel> list        = new List <StaffViewModel>();


            List <StaffDto>     staffs;
            HttpResponseMessage response = GlobalVariables.WebApiClient.GetAsync("Staff").Result;

            staffs = response.Content.ReadAsAsync <List <StaffDto> >().Result;

            foreach (var staff in staffs)
            {
                mappedStaff          = Mapper.MapStaff(staff);
                mappedStaff.Brunch   = BrunchLoader.GetInsertedById(staff.Brunch_id);
                mappedStaff.Position = PositionLoader.GetInsertedById(staff.Position_id);
                foreach (var orders in staff.Orsers_id)
                {
                    var order = MVCDataLoader.OrderLoader.GetInsertedById(orders);
                    mappedStaff.Orders.Add(order);
                }


                list.Add(mappedStaff);
            }
            return(list);
        }
Ejemplo n.º 2
0
        /// <summary>Lấy thông tin nhân viên theo id</summary>
        /// <param name="Id">The identifier.</param>
        /// <returns>
        ///   <br />
        /// </returns>
        /// <exception cref="ThainhLabExeption">Không tìm thấy nhân viên có Id: {Id}</exception>
        /// <Modified>
        /// Name     Date         Comments
        /// thainh2  5/10/2021   created
        /// </Modified>
        public async Task <StaffViewModel> GetById(int Id)
        {
            try
            {
                var staff = await _context.Staffs.FindAsync(Id);

                if (staff == null)
                {
                    throw new ThainhLabExeption($"Không tìm thấy nhân viên có Id: {Id}");
                }
                var staffVm = new StaffViewModel()
                {
                    Id    = staff.Id,
                    Name  = staff.Name,
                    Email = staff.Email,
                    Tel   = staff.Tel
                };

                return(staffVm);
            }
            catch (Exception e)
            {
                var logRequest = new LogWritelogRequest()
                {
                    MethodName  = "StaffService_GetById",
                    CreateDate  = DateTime.Now,
                    Description = e.Message
                };
                await WriteLog(logRequest);

                throw new ThainhLabExeption(e.Message);
            }
        }
Ejemplo n.º 3
0
        public static List <BrunchViewModel> GetBrunches()
        {
            BrunchViewModel        mappedBrunch = new BrunchViewModel();
            List <BrunchViewModel> list         = new List <BrunchViewModel>();


            IEnumerable <BrunchDto> brunchList;
            HttpResponseMessage     response = GlobalVariables.WebApiClient.GetAsync("Brunch").Result;

            brunchList = response.Content.ReadAsAsync <IEnumerable <BrunchDto> >().Result;

            foreach (var brunch in brunchList)
            {
                mappedBrunch = Mapper.MapBrunch(brunch);

                foreach (var item in brunch.OrdersId)
                {
                    OrderViewModel order = OrderLoader.GetOrder(item);
                    mappedBrunch.Orders.Add(order);
                }
                foreach (var item in brunch.StaffId)
                {
                    StaffViewModel staff = new StaffViewModel();
                    staff = StaffLoader.GetInsertedById(item);
                    mappedBrunch.Staff.Add(staff);
                }

                list.Add(mappedBrunch);
            }

            return(list);
        }
Ejemplo n.º 4
0
        public void ProvisionTenant(TenantViewModel tenant, StaffViewModel administrator)
        {
            ProvisionTenantCommand command = new ProvisionTenantCommand(
                tenant.Name,
                tenant.Description,
                administrator.FirstName,
                administrator.LastName,
                administrator.EmailAddress,
                administrator.PrimaryTelephone,
                administrator.SecondaryTelephone,
                administrator.AddressStreetAddress,
                administrator.AddressCity,
                administrator.AddressStateProvince,
                administrator.AddressPostalCode,
                administrator.AddressCountryCode
                );

            var _tenant = _identityApplicationService.ProvisionTenant(command).Result;

            TenantCreatedEvent tenantCreatedEvent = new TenantCreatedEvent(
                _tenant.Id,
                _tenant.Name,
                _tenant.Description
                );

            _eventPublisher.Publish <TenantCreatedEvent>(tenantCreatedEvent);
        }
Ejemplo n.º 5
0
        public void UpdateStaff(StaffViewModel objVM)
        {
            DBConnectionString.Profile profile = DBConnectionString.Profile.Fetch("select * from profile where userId=@0", objVM.UserId).SingleOrDefault();
            DBConnectionString.Staff   staff   = DBConnectionString.Staff.Fetch("select * from staff where userId=@0", objVM.UserId).SingleOrDefault();
            DBConnectionString.User    user    = DBConnectionString.User.Fetch("select * from Users where userId=@0", objVM.UserId).SingleOrDefault();

            if (profile != null)
            {
                profile.Title               = objVM.Title;
                profile.DateOfBirth         = objVM.DateOfBirth;
                profile.MobileNumber        = objVM.MobileNumber;
                profile.HomeTelephoneNumber = objVM.HomeTelephoneNumber;
                profile.EmailAddress1       = objVM.Email;
                profile.Update();
            }

            if (staff != null)
            {
                staff.StaffTypeId = objVM.StaffTypeId;
                staff.Email       = objVM.Email;
                staff.Update();
            }

            if (user != null)
            {
                user.FirstName = objVM.FirstName;
                user.LastName  = objVM.LastName;
                user.Email     = objVM.Email;
                user.Update();
            }
            objVM.StaffPermission.UserId = objVM.UserId;
            this.UpdateStaffPermissions(objVM.StaffPermission);
        }
Ejemplo n.º 6
0
        public ActionResult Index()
        {
            int    id  = 3;
            string str = HttpClientHelper.Send("get", "api/CheckApi/", null);
            List <CheckViewModel> list = JsonConvert.DeserializeObject <List <CheckViewModel> >(str);

            ViewBag.a = list;
            string str1 = HttpClientHelper.Send("get", "/api/StaffApi", null);
            List <StaffViewModel> list1 = JsonConvert.DeserializeObject <List <StaffViewModel> >(str1);
            StaffViewModel        aa    = (from a in list1.AsEnumerable()
                                           where a.StaffId == id
                                           select new StaffViewModel
            {
                HandImg = a.HandImg,
                StaffName = a.StaffName
            }).FirstOrDefault();

            ViewBag.img  = aa.HandImg;
            ViewBag.name = aa.StaffName;

            string str2 = HttpClientHelper.Send("get", "/api/LeaveApi", null);
            List <LeaveViewModel> list2 = JsonConvert.DeserializeObject <List <LeaveViewModel> >(str2);

            ViewBag.qj = from a in list2.AsEnumerable()
                         where a.StaffId == id
                         select a;

            return(View());
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> Delete(int id, int page)
        {
            Staff staff = await context.Staff.FindAsync(id);

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

            bool   deleteFlag = false;
            string message    = "Do you want to delete this entity";

            if (context.Containers.Any(s => s.TypeOfGsmid == staff.StaffId) && context.Costs.Any(s => s.TypeOfGsmid == staff.StaffId))
            {
                message = "This entity has entities, which dependents from this. Do you want to delete this entity and other, which dependents from this?";
            }

            StaffViewModel StaffViewModel = new StaffViewModel();

            StaffViewModel.Staff         = staff;
            StaffViewModel.PageViewModel = new PageViewModel {
                PageNumber = page
            };
            StaffViewModel.DeleteViewModel = new DeleteViewModels {
                Message = message, IsDeleted = deleteFlag
            };

            return(View(StaffViewModel));
        }
        public async Task <IActionResult> Delete(int id, int page)
        {
            Staff staff = await db.Staff.FindAsync(id);

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

            bool   deleteFlag = false;
            string message    = "Do you want to delete this entity";

            if (db.Timetables.Any(s => s.StaffId == staff.StaffId))
            {
                message = "This entity has entities, which dependents from this. Do you want to delete this entity and other, which dependents from this?";
            }

            StaffViewModel model = new StaffViewModel();

            model.Entity        = staff;
            model.PageViewModel = new PageViewModel {
                CurrentPage = page
            };
            model.DeleteViewModel = new DeleteViewModel {
                Message = message, IsDeleted = deleteFlag
            };

            return(View(model));
        }
        public IActionResult Index(SortState sortState = SortState.StaffFullNameAsc, int page = 1)
        {
            StaffFilterViewModel filter = HttpContext.Session.Get <StaffFilterViewModel>(filterKey);

            if (filter == null)
            {
                filter = new StaffFilterViewModel {
                    FullName = string.Empty, PositionName = string.Empty
                };
                HttpContext.Session.Set(filterKey, filter);
            }

            string modelKey = $"{typeof(Staff).Name}-{page}-{sortState}-{filter.FullName}-{filter.PositionName}";

            if (!cache.TryGetValue(modelKey, out StaffViewModel model))
            {
                model = new StaffViewModel();

                IQueryable <Staff> Staff = GetSortedEntities(sortState, filter);

                int count    = Staff.Count();
                int pageSize = 10;
                model.PageViewModel = new PageViewModel(page, count, pageSize);

                model.Entities             = count == 0 ? new List <Staff>() : Staff.Skip((model.PageViewModel.CurrentPage - 1) * pageSize).Take(pageSize).ToList();
                model.SortViewModel        = new SortViewModel(sortState);
                model.StaffFilterViewModel = filter;

                cache.Set(modelKey, model);
            }

            return(View(model));
        }
        public IActionResult GetTotalTime(int id, int page)
        {
            StaffViewModel model = new StaffViewModel {
                PageViewModel = new PageViewModel {
                    CurrentPage = page
                }
            };

            Staff staff = db.Staff.Find(id);

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

            model.Entity = staff;

            DateTime date = DateTime.Today;

            model.TotalTime = db.Shows.
                              Join(db.Timetables, s => s.ShowId, t => t.ShowId, (s, t) => new { s, t })
                              .Where(q => q.t.StaffId == id && q.t.Year == date.Year && q.t.Month == date.Month)
                              .Select(q => q.s.Duration)
                              .AsEnumerable()
                              .Aggregate(TimeSpan.Zero, (subtotal, t) => subtotal.Add(t));

            return(View(model));
        }
        public async Task <IActionResult> Create(StaffViewModel model)
        {
            model.SelectList = db.Positions.Select(p => p.Name).ToList();

            var position = db.Positions.FirstOrDefault(g => g.Name == model.PositionName);

            if (position == null)
            {
                ModelState.AddModelError(string.Empty, "Please select position from list.");
                return(View(model));
            }

            if (ModelState.IsValid & CheckUniqueValues(model.Entity))
            {
                model.Entity.PositionId = position.PositionId;

                await db.Staff.AddAsync(model.Entity);

                await db.SaveChangesAsync();

                cache.Clean();

                return(RedirectToAction("Index"));
            }

            return(View(model));
        }
Ejemplo n.º 12
0
        public IHttpActionResult updateUser([FromBody] StaffViewModel model)
        {
            // var logInUserName = RequestContext.Principal.Identity.Name;
            var u = db.Users.Find(model.id);

            if (u != null)
            {
                var d  = (model.dept_id != null) ? db.department.Find(model.dept_id) : null;
                var du = (model.unit_id != null) ? db.dept_unit.Find(model.unit_id) : null;
                var r  = (model.role_id != null) ? db.Roles.Find(model.role_id) : null;
                u.Fname          = model.Fname;
                u.LName          = model.Lname;
                u.stateOffice    = model.stateOffice;
                u.regionalOffice = model.regionalOffice;
                u.staffType      = model.staffType;
                u.dept_name      = (d != null) ? d.dept_name : null;
                u.dept_id        = (d != null)?d.id : null;
                u.unit_id        = (du != null)?du.id:null;
                u.unit_name      = (du != null) ? du.unit_name : null;
                u.rolename       = (r != null) ? r.Name : null;
                u.rank           = model.rank;
                db.SaveChanges();
                return(Ok());
            }
            else
            {
                return(NotFound());
            }
        }
Ejemplo n.º 13
0
        public IHttpActionResult getuser(string id)
        {
            var logInUserName = RequestContext.Principal.Identity.Name;
            var u             = db.Users.Find(id);

            if (u != null)
            {
                var us = new StaffViewModel
                {
                    id             = u.Id,
                    Fname          = u.Fname,
                    Lname          = u.LName,
                    staffType      = u.staffType,
                    stateOffice    = u.stateOffice,
                    regionalOffice = u.regionalOffice,
                    dept_name      = u.dept_name,
                    unit_name      = u.unit_name,
                    username       = u.UserName,
                    role_id        = (!string.IsNullOrEmpty(u.rolename))?u.Roles.First(r => r.UserId == u.Id).RoleId:null,
                    dept_id        = u.dept_id,
                    unit_id        = u.unit_id,
                    rank           = u.rank
                };
                ulog.loguserActivities(logInUserName, "User requested for registered users List");
                return(Ok(us));
            }
            else
            {
                return(NotFound());
            }
        }
Ejemplo n.º 14
0
        public async Task <IHttpActionResult> Post(StaffViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                var stf = await _staffService.InsertAsync(model, GetCurrentUserID());

                _unitOfWorkAsync.Commit();
                var resultObject = new StaffViewModel()
                {
                    FullName = stf.FullName,
                    Email    = stf.Email,
                    ID       = stf.Id,
                };
                return(Created(resultObject));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Deletes entity for StaffViewModel.
        /// </summary>
        /// <param name="viewModel">The viewModel <see cref="StaffViewModel"/>.</param>
        /// <returns>The <see cref="SimpleResponse"/>.</returns>
        public SimpleResponse Delete(StaffViewModel model)
        {
            var response = new SimpleResponse();

            try
            {
                using (var context = new PublicCoreDbContext())
                {
                    var entity = context.Staff.SingleOrDefault(q => q.StaffId == model.StaffId);
                    if (entity == null || entity == default(Staff))
                    {
                        response.ResponseCode    = BusinessResponseValues.NullEntityValue;
                        response.ResponseMessage = "Kayýt bulunamadý.";
                        return(response);
                    }

                    context.Staff.Remove(entity);
                    response.ResponseCode = context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                response.ResponseCode    = BusinessResponseValues.InternalError;
                response.ResponseMessage = "Silme iþleminde hata oluþtu.";
                DayLogger.Error(ex);
            }

            return(response);
        }
        public IActionResult Index(StaffViewModel filterModel, string positionName)
        {
            StaffFilterViewModel filter;

            if (!string.IsNullOrEmpty(positionName))
            {
                filter = new StaffFilterViewModel {
                    PositionName = positionName
                };
                HttpContext.Session.Set(filterKey, filter);

                return(RedirectToAction("Index", new { page = 1 }));
            }

            filter = HttpContext.Session.Get <StaffFilterViewModel>(filterKey);
            if (filter != null)
            {
                filter.FullName     = filterModel.StaffFilterViewModel.FullName;
                filter.PositionName = filterModel.StaffFilterViewModel.PositionName;

                HttpContext.Session.Remove(filterKey);
                HttpContext.Session.Set(filterKey, filter);
            }

            return(RedirectToAction("Index", new { page = 1 }));
        }
Ejemplo n.º 17
0
        /// <summary>
        /// The Creates entity for StaffViewModel.
        /// </summary>
        /// <param name="viewModel">The viewModel <see cref="StaffViewModel"/>.</param>
        /// <returns>The <see cref="SimpleResponse{StaffViewModel}"/>.</returns>
        public SimpleResponse <StaffViewModel> Create(StaffViewModel model)
        {
            var response = new SimpleResponse <StaffViewModel>();

            try
            {
                var validation = model.Validate();
                if (validation.HasError)
                {
                    return(new SimpleResponse <StaffViewModel>
                    {
                        Data = model,
                        ResponseCode = BusinessResponseValues.ValidationErrorResult,
                        ResponseMessage = validation.AllValidationMessages
                    });
                }

                using (var context = new PublicCoreDbContext())
                {
                    var entity = Map <StaffViewModel, Staff>(model);
                    context.Staff.Add(entity);
                    response.ResponseCode = context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                response.ResponseCode    = BusinessResponseValues.InternalError;
                response.ResponseMessage = "Ekleme iþleminde hata oluþtu.";
                DayLogger.Error(ex);
            }

            return(response);
        }
Ejemplo n.º 18
0
        public StaffViewModel MapToStaffVM(Staff staff)
        {
            string branchName = "";

            if (staff.BranchNo != null)
            {
                List <Branch> branchList = branchContext.GetAllBranches();
                foreach (Branch branch in branchList)
                {
                    if (branch.BranchNo == staff.BranchNo.Value)
                    {
                        branchName = branch.Address;
                        //Exit the foreach loop once the name is found
                        break;
                    }
                }
            }
            StaffViewModel staffVM = new StaffViewModel
            {
                StaffId     = staff.StaffId,
                Name        = staff.Name,
                Gender      = staff.Gender,
                DOB         = staff.DOB,
                Nationality = staff.Nationality,
                Email       = staff.Email,
                Salary      = staff.Salary,
                Status      = staff.IsFullTime ? "Full-Time" : "Part-Time",
                BranchName  = branchName,
                Photo       = staff.Name + ".jpg"
            };

            return(staffVM);
        }
Ejemplo n.º 19
0
        public async Task <IActionResult> Edit(StaffViewModel StaffViewModel)
        {
            if (ModelState.IsValid)
            {
                Staff staff = context.Staff.Find(StaffViewModel.Staff.StaffId);
                if (staff != null)
                {
                    staff.FullName             = StaffViewModel.Staff.FullName;
                    staff.StaffAge             = StaffViewModel.Staff.StaffAge;
                    staff.StaffFunction        = StaffViewModel.Staff.StaffFunction;
                    staff.WorkingHoursForAweek = StaffViewModel.Staff.WorkingHoursForAweek;

                    context.Staff.Update(staff);
                    await context.SaveChangesAsync();

                    cache.Clean();
                    return(RedirectToAction("Index", "Staff", new { page = StaffViewModel.PageViewModel.PageNumber }));
                }
                else
                {
                    return(NotFound());
                }
            }

            return(View(StaffViewModel));
        }
        public IActionResult Add()
        {
            //EditCustomerViewModel editCustomer = new EditCustomerViewModel();
            var staff = new StaffViewModel();

            return(View(staff));
        }
Ejemplo n.º 21
0
        public IActionResult Index(SortState sortState = SortState.FullNameAsc, int page = 1)
        {
            StaffFilterViewModel filter = HttpContext.Session.Get <StaffFilterViewModel>(filterKey);

            if (filter == null)
            {
                filter = new StaffFilterViewModel {
                    FullName = string.Empty, StaffAge = 0, StaffFunction = string.Empty, WorkingHoursForAweek = 0
                };
                HttpContext.Session.Set(filterKey, filter);
            }

            string modelKey = $"{typeof(Staff).Name}-{page}-{sortState}-{filter.FullName}-{filter.StaffAge}-{filter.StaffFunction}-{filter.WorkingHoursForAweek}";

            if (!cache.TryGetValue(modelKey, out StaffViewModel model))
            {
                model = new StaffViewModel();

                IQueryable <Staff> staff = GetSortedEntities(sortState, filter.FullName, filter.StaffAge, filter.StaffFunction, filter.WorkingHoursForAweek);

                int count    = staff.Count();
                int pageSize = 10;
                model.PageViewModel = new PageViewModel(count, page, pageSize);

                model.Staffs               = count == 0 ? new List <Staff>() : staff.Skip((model.PageViewModel.PageNumber - 1) * pageSize).Take(pageSize).ToList();
                model.SortViewModel        = new SortViewModel(sortState);
                model.StaffFilterViewModel = filter;

                cache.Set(modelKey, model);
            }

            return(View(model));
        }
Ejemplo n.º 22
0
        // GET: Staffs/Edit/5
        public async Task <IActionResult> Edit(int?id, StaffViewModel model)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var staff = await _context.Staff
                        .Include(s => s.Person)
                        .Include(s => s.Contact)
                        .FirstOrDefaultAsync(m => m.StaffId == id);

            model.FirstName = staff.Person.FirstName;
            model.LastName  = staff.Person.LastName;
            model.Dob       = staff.Person.Dob;
            model.Address   = staff.Person.Address;

            model.Email     = staff.Contact.Email;
            model.Phone     = staff.Contact.Phone;
            model.Hours     = staff.Hours;
            model.StartDate = staff.StartDate;
            if (staff.LeftDate != null)
            {
                model.LeftDate = staff.LeftDate;
            }

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

            return(View(model));
        }
Ejemplo n.º 23
0
        public async Task <IActionResult> Post([FromBody] StaffViewModel staff)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var newStaffMember = new Staff {
                        FirstName = staff.FirstName, LastName = staff.LastName, Age = staff.Age
                    };
                    var createdStaffId = await _repository.CreateStaffAsync(newStaffMember);

                    var newStaffDetails = new StaffJobDetails {
                        StaffID = createdStaffId, JobTitle = staff.JobTitle, StartDate = DateTime.Now, SalaryGrade = staff.SalaryGrade
                    };
                    await _repository.CreateStaffJobDetailsAsync(newStaffDetails);

                    return(Created($"api/staff/{staff.FullName}", staff));
                }
                catch (Exception ex)
                {
                    _logger.LogError($"Failed to get Staff: {ex}");

                    Response.StatusCode = StatusCodes.Status503ServiceUnavailable;
                }
            }

            return(new BadRequestObjectResult(ModelState));
        }
        public ActionResult Staff_Save(StaffViewModel obj)
        {
            try
            {
                if (obj != null)
                {
                    ServicioStaff servicio = new ServicioStaff();
                    Random        grdn     = new Random();
                    //para identificar si es boleta 1 - boleta virtual 2 - manilla 3 - escarapela 4
                    var identificardor = "4";
                    var year           = DateTime.Now.Year.ToString().Substring(2, 2);
                    var month          = DateTime.Now.Month.ToString();
                    var day            = DateTime.Now.Day.ToString();
                    var min            = DateTime.Now.Minute.ToString();
                    var seg            = DateTime.Now.Second.ToString();
                    obj.Auditoria.IdCreatorby = Utilidades.GetCurrentUser().Id;
                    obj.Auditoria.DateCreated = DateTime.Now;
                    obj.CodigoUnico           = string.Format("{0}{1}{2}{3}{4}{5}{6}{7}{8}", identificardor, grdn.Next(1000), year, grdn.Next(1000), month, grdn.Next(1000), day, min, seg);
                    servicio.AsociarStaff(obj);

                    return(Json(new
                    {
                        execute = (obj.Id > 0)?true:false,
                        messagge = "El usuario a sido asociado al evento"
                    }, JsonRequestBehavior.AllowGet));
                }
                return(null);
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 25
0
        public IHttpActionResult UpdatePost(StaffViewModel model)
        {
            var response = new SimpleResponse();

            response = iStaffBusiness.Update(model);
            return(Json(response));
        }
Ejemplo n.º 26
0
        public async Task <IActionResult> Create(StaffViewModel model)
        {
            var states = await _stateService.GetStates();

            var ranks = RankExtensions.GetRanks();

            if (ModelState.IsValid)
            {
                var response = await _staffService.AddStaff(model.FirstName, model.LastName, model.MiddleName,
                                                            model.ArmyNumber, model.PhoneNumber, model.Address, model.Rank, model.State, model.BirthDate,
                                                            model.RetirementDate);

                ViewBag.Error   = !response.Status;
                ViewBag.Message = response.Message;
                ViewBag.States  = new SelectList(states, "Key", "Value");
                ViewBag.Ranks   = new SelectList(ranks, "Key", "Value");
                return(View(new StaffViewModel()));
            }
            else
            {
                ViewBag.Error   = true;
                ViewBag.Message = "Kindly fill the form correctly!";
                ViewBag.States  = new SelectList(states, "Key", "Value", model.State);
                ViewBag.Ranks   = new SelectList(ranks, "Key", "Value", model.Rank);
                return(View(model));
            }
        }
Ejemplo n.º 27
0
        public StaffViewModel AddStaff(StaffViewModel entity)
        {
            var data = new tbl_Staff
            {
                StaffId            = entity.staffId,
                FirstName          = entity.firstName,
                LastName           = entity.lastName,
                OtherName          = entity.otherName,
                PhoneNo            = entity.phoneNo,
                AlternativePhoneNo = entity.alternativePhoneNo,
                Address            = entity.address,
                Email            = entity.email,
                AlternativeEmail = entity.alternativeEmail,
                Designation      = entity.designation,
                IsActive         = entity.isActive,
                CreatedOn        = DateTime.Now,
                CreatedBy        = "admin",
                ModifiedBy       = "admin",
                ModifiedOn       = DateTime.Now
            };

            context.tbl_Staff.Add(data);
            context.SaveChanges();
            return(entity);
        }
Ejemplo n.º 28
0
        public async Task <IActionResult> Edit(int id)
        {
            var staff = await _staffService.GetStaffAsync(id);

            if (staff == null)
            {
                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                var states = await _stateService.GetStates();

                var ranks = RankExtensions.GetRanks();
                ViewBag.States = new SelectList(states, "Key", "Value", staff.StateId);
                ViewBag.Ranks  = new SelectList(ranks, "Key", "Value", staff.RankId);

                var viewModel = new StaffViewModel
                {
                    Rank      = staff.RankId, LastName = staff.LastName, FirstName = staff.FirstName,
                    State     = staff.StateId, ArmyNumber = staff.ArmyNumber, PhoneNumber = staff.PhoneNumber,
                    BirthDate = staff.BirthDate, RetirementDate = staff.RetirementDate,
                    Address   = staff.Address, MiddleName = staff.MiddleName, Id = staff.Id
                };
                return(View(viewModel));
            }
        }
Ejemplo n.º 29
0
        public StaffViewModel LoadViewModel()
        {
            StaffViewModel objVM     = new StaffViewModel();
            ListFields     objFields = null;

            objVM.ListFields = new List <ListFields>();

            SelectList classList      = null;
            SelectList courseList     = null;
            SelectList sectionList    = null;
            SelectList departmentList = null;
            SelectList subjectList    = null;
            SelectList staffTypeList  = null;

            this.LoadSelectLists(out classList, out courseList, out sectionList, out departmentList, out subjectList, out staffTypeList, false);

            for (int i = 0; i < 10; i++)
            {
                objFields                = new ListFields();
                objFields.CourseList     = courseList;
                objFields.DepartmentList = departmentList;
                objFields.ClassList      = classList;
                objFields.SectionList    = sectionList;
                objFields.SubjectList    = subjectList;
                objVM.ListFields.Add(objFields);
            }
            objVM.StaffTypeList = staffTypeList;
            return(objVM);
        }
Ejemplo n.º 30
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            LoggedStaff             = (StaffViewModel)e.Parameter;
            tbStaffName.DataContext = LoggedStaff;
        }