public ActionResult Create(EmployeeAddressDTO Record)
 {
     ViewBag.EmployeeDetail       = _employeeService.GetEmployeeDetails(Record.Id);
     ViewBag.SideBar              = _moduleService.AdminEmployeeDetailsMenu(Record.Id);
     Record.DistrictSelectList    = _employeeService.GetDistrictSelectList();
     Record.ZoneSelectList        = _employeeService.GetZoneSelectList();
     Record.CountrySelectList     = _countryService.GetCountryList().ToList();
     Record.AddressTypeSelectList = _employeeService.GetAddressTypeSelectList();
     try
     {
         if (ModelState.IsValid)
         {
             _employeeService.CreateEmployeeAddress(Record);
             TempData["Success"] = "Address created successfully.";
         }
         else
         {
             TempData["Danger"] = "Please fill in the required field.";
             return(View("../Employee/Address/Create", Record));
         }
     }catch (Exception Exception)
     {
         TempData["Danger"] = Exception.Message;
         return(View("../Employee/Address/Create", Record));
     }
     return(RedirectToAction("Index", new { Id = Record.EmployeeCode }));
 }
Beispiel #2
0
        public static EmployeeAddressDTO ConvertEmployeeAddressToDTO(EmployeeAddress Item)
        {
            EmployeeAddressDTO Record = new EmployeeAddressDTO
            {
                Id           = Item.Id,
                EmployeeCode = Item.EmployeeCode,
                HouseNumber  = Item.HouseNumber,
                WardNumber   = Item.WardNumber,
                VDC          = Item.VDC,
                District     = Item.District,
                Zone         = Item.Zone,
                State        = Item.State,
                Country      = Item.Country,
                LandMark     = Item.LandMark,
                AddressType  = Item.AddressType,
                Employee     = new EmployeeDTO
                {
                    EmpName = Item.Employee.EmpName
                },
                Zone1 = new ZoneDTO
                {
                    ZoneName = Item.Zone1.ZoneName,
                },
                District1 = new DistrictDTO
                {
                    DistrictName = Item.District1.DistrictName,
                },
                Country1 = new CountryDTO
                {
                    CountryName = Item.Country1.CountryName
                }
            };

            return(Record);
        }
        public ActionResult Edit(int Id)
        {
            EmployeeAddressDTO Record = _employeeService.GetAddressById(Id);

            ViewBag.EmployeeDetail       = _employeeService.GetEmployeeDetails(Record.EmployeeCode);
            ViewBag.SideBar              = _moduleService.AdminEmployeeDetailsMenu(Record.EmployeeCode);
            Record.DistrictSelectList    = _employeeService.GetDistrictSelectList();
            Record.ZoneSelectList        = _employeeService.GetZoneSelectList();
            Record.CountrySelectList     = _countryService.GetCountryList().ToList();
            Record.AddressTypeSelectList = _employeeService.GetAddressTypeSelectList();
            return(View("../Employee/Address/Edit", Record));
        }
        public ActionResult Create(int Id)
        {
            ViewBag.EmployeeDetail = _employeeService.GetEmployeeDetails(Id);
            ViewBag.SideBar        = _moduleService.AdminEmployeeDetailsMenu(Id);
            EmployeeAddressDTO Record = new EmployeeAddressDTO();

            Record.EmployeeCode          = Id;
            Record.DistrictSelectList    = _employeeService.GetDistrictSelectList();
            Record.ZoneSelectList        = _employeeService.GetZoneSelectList();
            Record.CountrySelectList     = _countryService.GetCountryList().ToList();
            Record.AddressTypeSelectList = _employeeService.GetAddressTypeSelectList();
            return(View("../Employee/Address/Create", Record));
        }
Beispiel #5
0
        public static EmployeeAddress ConvertEmployeeAddressFromDTO(EmployeeAddressDTO Item)
        {
            EmployeeAddress Record = new EmployeeAddress
            {
                Id           = Item.Id,
                EmployeeCode = Item.EmployeeCode,
                HouseNumber  = Convert.ToInt32(Item.HouseNumber),
                WardNumber   = Convert.ToInt32(Item.WardNumber),
                VDC          = Item.VDC,
                District     = Item.District,
                Zone         = Item.Zone,
                State        = Item.State,
                Country      = Item.Country,
                LandMark     = Item.LandMark,
                AddressType  = Item.AddressType,
            };

            return(Record);
        }
Beispiel #6
0
        public string Execute(string[] parameters)
        {
            int    targetingId = int.Parse(parameters[0]);
            string address     = string.Join(" ", parameters.Skip(1));

            Emoloyee employee = this.context.Emoloyees.Find(targetingId);

            if (employee == null)
            {
                throw new ArgumentNullException($"Employee with id {targetingId} does not exist.");
            }

            employee.Address = address;
            this.context.SaveChanges();

            EmployeeAddressDTO employeeDTO = this.mapper.CreateMappedObject <EmployeeAddressDTO>(employee);

            return($"{employeeDTO.FirstName} {employeeDTO.LastName}'s adress was set to {employeeDTO.Address} successfuly.");
        }
        public static IEnumerable <EmployeeAddressDTO> ModelData(IEnumerable <EmployeeAddress> modelData)
        {
            List <EmployeeAddressDTO> Record = new List <EmployeeAddressDTO>();

            foreach (EmployeeAddress Item in modelData)
            {
                EmployeeAddressDTO Singles = new EmployeeAddressDTO
                {
                    Id           = Item.Id,
                    EmployeeCode = Item.EmployeeCode,
                    HouseNumber  = Item.HouseNumber,
                    WardNumber   = Item.WardNumber,
                    VDC          = Item.VDC,
                    District     = Item.District,
                    Zone         = Item.Zone,
                    State        = Item.State,
                    Country      = Item.Country,
                    LandMark     = Item.LandMark,
                    AddressType  = Item.AddressType,
                    Employee     = new EmployeeDTO
                    {
                        EmpName = Item.Employee.EmpName
                    },
                    Zone1 = new ZoneDTO
                    {
                        ZoneName = Item.Zone1.ZoneName,
                    },
                    District1 = new DistrictDTO
                    {
                        DistrictName = Item.District1.DistrictName,
                    },
                    Country1 = new CountryDTO
                    {
                        CountryName = Item.Country1.CountryName
                    }
                };
                Record.Add(Singles);
            }
            return(Record);
        }