Example #1
0
        public List <StaffApiModel> Map(List <Staff> staffList)
        {
            List <StaffApiModel> staffApiModelList = new List <StaffApiModel>();

            foreach (var staff in staffList)
            {
                var staffListApiModel = new StaffApiModel();

                staffListApiModel.Id           = staff.Id;
                staffListApiModel.StaffType    = staff.StaffType;
                staffListApiModel.FirstName    = staff.FirstName;
                staffListApiModel.LastName     = staff.LastName;
                staffListApiModel.MobileNumber = staff.MobileNumber;
                staffListApiModel.AadharNumber = staff.AadharNumber;
                staffListApiModel.Address      = staff.Address;
                // staffListApiModel.UnitId = staff.UnitStaff.ForEach
                if (staff.UnitStaff != null)
                {
                    staffListApiModel.UnitIdList = new List <Guid>();
                    foreach (var unitStaff in staff.UnitStaff)
                    {
                        staffListApiModel.UnitIdList.Add(unitStaff.UnitId);
                    }
                }
                staffApiModelList.Add(staffListApiModel);
            }
            return(staffApiModelList);
        }
Example #2
0
        public ActionResult Add(Guid communityId, StaffApiModel staffApiModel)
        {
            try
            {
                var staff = _staffMapper.Map(staffApiModel);

                var serviceResponse = this._staffService.Add(communityId, staff, staffApiModel.UnitIdList);
                return(SendResponse(serviceResponse, "Staff"));
            }
            catch (Exception ex)
            {
                return(new UnknownErrorResult(ex, base._errorEnabled));
            }
        }
Example #3
0
        public Staff Map(StaffApiModel staffApiModel, Staff staff = null)
        {
            if (staff == null)
            {
                staff = new Staff();
            }

            staff.StaffType    = staffApiModel.StaffType;
            staff.FirstName    = staffApiModel.FirstName;
            staff.LastName     = staffApiModel.LastName;
            staff.MobileNumber = staffApiModel.MobileNumber;
            staff.Address      = staffApiModel.Address;
            staff.AadharNumber = staffApiModel.AadharNumber;

            return(staff);
        }
Example #4
0
        public StaffApiModel Map(Staff staff, StaffApiModel staffApiModel = null)
        {
            if (staffApiModel == null)
            {
                staffApiModel = new StaffApiModel();
            }

            staffApiModel.StaffType    = staff.StaffType;
            staffApiModel.FirstName    = staff.FirstName;
            staffApiModel.LastName     = staff.LastName;
            staffApiModel.MobileNumber = staff.MobileNumber;
            staffApiModel.Address      = staff.Address;
            staffApiModel.AadharNumber = staff.AadharNumber;
            staffApiModel.CommunityId  = staff.CommunityId;
            return(staffApiModel);
        }
Example #5
0
        public List <StaffApiModel> Map(List <UnitStaff> unitStaffList)
        {
            List <StaffApiModel> staffApiModelList = new List <StaffApiModel>();

            foreach (var unitStaff in unitStaffList)
            {
                var staffApiModel = new StaffApiModel();

                staffApiModel.Id           = unitStaff.StaffId;
                staffApiModel.StaffType    = unitStaff.Staff.StaffType;
                staffApiModel.FirstName    = unitStaff.Staff.FirstName;
                staffApiModel.LastName     = unitStaff.Staff.LastName;
                staffApiModel.MobileNumber = unitStaff.Staff.MobileNumber;
                staffApiModel.AadharNumber = unitStaff.Staff.AadharNumber;
                staffApiModelList.Add(staffApiModel);
            }
            return(staffApiModelList);
        }
Example #6
0
        public ActionResult Update(Guid id, StaffApiModel staffApiModel)
        {
            try
            {
                ApiResponse serviceResponse = this._staffService.GetSingle(id);
                if (serviceResponse.IsSuccess() == false)
                {
                    return(new ObjectNotFoundResult(serviceResponse));
                }

                Staff staff = serviceResponse.GetData <Staff>();
                _staffMapper.Map(staffApiModel, staff);
                serviceResponse = this._staffService.Update(staff, staffApiModel.UnitIdList);
                return(SendResponse(serviceResponse));
            }
            catch (Exception ex)
            {
                return(new UnknownErrorResult(ex, base._errorEnabled));
            }
        }