public async Task <IActionResult> Create([Bind("EmpId,EmpFirstName,EmpMiddleName,EmpLastName,Gender,EmpCode,DOB,ImagePath,Profession,Designation,DOJ,YearOfexp,BasicSalary,HRAAmt,TransportAmt,OtherAllowanceAmt,Address,PermanentAddress,ContactNo,LandlineNo,EmergencyNo,Email,FaxNo,HomeLandNo,Extension,PostCode,LanguageId,CurrencyId,StateId,CityId,CountryId,VisaNo,VisaStatus,VisaIssueDate,VisaExpDate,ExpatNo,InsCardNo,InsExpDate,LicIssueDate,LicExpiryDate,InsProviderID,EmiratesId,IdentificationDocID,LicenseType,LicenseNo,LicenseIssuePlace,VehicleNo,Weburl,PassportNo,PlaceOfIssue,EmpDirectStatus,EmpIndirectSupID,LastAnnualLeave,DateofResign,DateofRelieve,EmpStartDate,EmpEndDate,BranchId,RepToMangr,CompanyEmail,NationalityID,Description,Status,CompanyID,CreatedOn,CreatedBy,ModifiedBy,ModifiedOn,IP")] Employee employee, IFormFile file)
        {
            if (ModelState.IsValid)
            {
                employee.Status     = AppConstant.Active;
                employee.CompanyID  = AppConstant.CompanyID;
                employee.CreatedOn  = DateTime.Now;
                employee.ModifiedOn = DateTime.Now;
                employee.IP         = GetIPAddress.getExternalIp();
                _context.Add(employee);
                await _context.SaveChangesAsync();

                // Code to upload image
                if (file != null || file.Length != 0)
                {
                    FileInfo fi          = new FileInfo(file.FileName);
                    var      newFilename = employee.EmpId + "_" + String.Format("{0:d}", (DateTime.Now.Ticks / 10) % 100000000) + fi.Extension;
                    var      webPath     = hostingEnvironment.WebRootPath;
                    var      path        = Path.Combine("", webPath + @"\ImageFiles\" + newFilename);
                    var      pathToSave  = @"/ImageFiles/" + newFilename;
                    using (var stream = new FileStream(path, FileMode.Create))
                    {
                        await file.CopyToAsync(stream);
                    }
                    employee.ImagePath = pathToSave;
                    _context.Update(employee);
                    await _context.SaveChangesAsync();
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(employee));
        }
示例#2
0
 public async Task <IActionResult> Create(MyViewModel model)
 {
     if (ModelState.IsValid)
     {
         {
             Customer cus = new Customer();
             cus.CustName        = model.CustName;
             cus.CustCode        = model.CustCode;
             cus.CustTrnNo       = model.CustTrnNo;
             cus.CustLoginEnable = model.CustLoginEnable;
             cus.Status          = AppConstant.Active;
             cus.CompanyID       = AppConstant.CompanyID;
             cus.CreatedOn       = DateTime.Now;
             cus.ModifiedOn      = DateTime.Now;
             cus.IP = GetIPAddress.getExternalIp();
             _context.Customer.Add(cus);
             await _context.SaveChangesAsync();
         }
         {
             Address add = new Address();
             add.AddressAprtNo          = model.AddressAprtNo;
             add.AddressFloorNo         = model.AddressFloorNo;
             add.AddressBuildingNo      = model.AddressBuildingNo;
             add.AddressBuildingName    = model.AddressBuildingName;
             add.AddressStreetName      = model.AddressStreetName;
             add.AddressStreetNo        = model.AddressStreetNo;
             add.AddressAreaCode        = model.AddressAreaCode;
             add.AddressAreaName        = model.AddressAreaName;
             add.AddressCity            = model.AddressCity;
             add.AddressDistrict        = model.AddressDistrict;
             add.AddressState           = model.AddressState;
             add.AddressCountry         = model.AddressCountry;
             add.AddressContactNo1      = model.AddressContactNo1;
             add.AddressContactNo2      = model.AddressContactNo2;
             add.AddressEmailId1        = model.AddressEmailId1;
             add.AddressEmailId2        = model.AddressEmailId2;
             add.AddressContactPerson1  = model.AddressContactPerson1;
             add.AddressContactPerson2  = model.AddressContactPerson2;
             add.AddressLatLoc          = model.AddressLatLoc;
             add.AddressLongLoc         = model.AddressLongLoc;
             add.AddressUrl             = model.AddressUrl;
             add.AddressClosestLandMark = model.AddressClosestLandMark;
             add.AddressField1          = model.AddressField1;
             add.AddressField2          = model.AddressField2;
             add.AddressField3          = model.AddressField3;
             add.AddressField4          = model.AddressField4;
             add.AddressField5          = model.AddressField5;
             _context.Address.Add(add);
             await _context.SaveChangesAsync();
         }
         {
             return(RedirectToAction(nameof(Index)));
         }
     }
     return(View(model));
 }
        public async Task <IActionResult> Edit([Bind("EmpId,EmpFirstName,EmpMiddleName,EmpLastName,Gender,EmpCode,DOB,ImageUrl,Profession,Designation,DOJ,YearOfexp,BasicSalary,HRAAmt,TransportAmt,OtherAllowanceAmt,Address,PermanentAddress,ContactNo,LandlineNo,EmergencyNo,Email,FaxNo,HomeLandNo,Extension,PostCode,LanguageId,CurrencyId,StateId,CityId,CountryId,VisaNo,VisaStatus,VisaIssueDate,VisaExpDate,ExpatNo,InsCardNo,InsExpDate,LicIssueDate,LicExpiryDate,InsProviderID,EmiratesId,IdentificationDocID,LicenseType,LicenseNo,LicenseIssuePlace,VehicleNo,Weburl,PassportNo,PlaceOfIssue,EmpDirectStatus,EmpIndirectSupID,LastAnnualLeave,DateofResign,DateofRelieve,EmpStartDate,EmpEndDate,BranchId,RepToMangr,CompanyEmail,NationalityID,Description,Status,CompanyID,CreatedOn,CreatedBy,ModifiedBy,ModifiedOn,IP")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                employee.ModifiedOn = DateTime.Now;
                employee.IP         = GetIPAddress.getExternalIp();
                _context.Update(employee);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(employee));
        }
        public async Task <IActionResult> Edit([Bind("BrandId,BrandName,BrandCode,Description,Status,MfrId,CompanyID,CreatedOn,CreatedBy,ModifiedBy,ModifiedOn,IP")] Brand brand)
        {
            if (ModelState.IsValid)
            {
                brand.ModifiedOn = DateTime.Now;
                brand.IP         = GetIPAddress.getExternalIp();
                _context.Update(brand);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(brand));
        }
示例#5
0
        public async Task <IActionResult> Edit([Bind("CountryId,CountryName,CountryCode,callingCode,Status,CompanyID,CreatedOn,CreatedBy,ModifiedBy,ModifiedOn,IP")] Country country)
        {
            if (ModelState.IsValid)
            {
                country.ModifiedOn = DateTime.Now;
                country.IP         = GetIPAddress.getExternalIp();
                _context.Update(country);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(country));
        }
示例#6
0
        public async Task <IActionResult> Edit([Bind("VehLicTypeId,VehLicTypeName,VehLicTypeCode,Description,Status,CompanyID,CreatedOn,CreatedBy,ModifiedBy,ModifiedOn,IP")] VehicleLicenceType vehicleLicenceType)
        {
            if (ModelState.IsValid)
            {
                vehicleLicenceType.ModifiedOn = DateTime.Now;
                vehicleLicenceType.IP         = GetIPAddress.getExternalIp();
                _context.Update(vehicleLicenceType);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(vehicleLicenceType));
        }
        public async Task <IActionResult> Edit([Bind("DgClassDangerousId,DgClassDangerousName,DgClassDangerousCode,DgClassDangerousDescription,Status,CompanyID,CreatedOn,CreatedBy,ModifiedBy,ModifiedOn,IP")] DgClassDangerous dgClassDangerous)
        {
            if (ModelState.IsValid)
            {
                dgClassDangerous.ModifiedOn = DateTime.Now;
                dgClassDangerous.IP         = GetIPAddress.getExternalIp();
                _context.Update(dgClassDangerous);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(dgClassDangerous));
        }
        public async Task <IActionResult> Edit([Bind("StateId,StateName,StateCode,CountryId,Status,CompanyID,CreatedOn,CreatedBy,ModifiedBy,ModifiedOn,IP")] State state)
        {
            if (ModelState.IsValid)
            {
                state.ModifiedOn = DateTime.Now;
                state.IP         = GetIPAddress.getExternalIp();
                _context.Update(state);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(state));
        }
示例#9
0
        public async Task <IActionResult> Edit([Bind("EmpSkillSetId,EmpSkillSetName,EmpSkillSetCode,Description,Status,CompanyID,CreatedOn,CreatedBy,ModifiedBy,ModifiedOn,IP")] EmpSkillSet empSkillSet)
        {
            if (ModelState.IsValid)
            {
                empSkillSet.ModifiedOn = DateTime.Now;
                empSkillSet.IP         = GetIPAddress.getExternalIp();
                _context.Update(empSkillSet);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(empSkillSet));
        }
示例#10
0
        public async Task <IActionResult> Edit(MyViewModel model)
        {
            if (ModelState.IsValid)
            {
                Customer cus = new Customer();
                cus.ModifiedOn = DateTime.Now;
                cus.IP         = GetIPAddress.getExternalIp();
                _context.Customer.Update(cus);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(model));
        }
        public async Task <IActionResult> Create([Bind("VehPlatePrefixId,VehPlatePrefixName,VehPlatePrefixCode,Description,Status,CompanyID,CreatedOn,CreatedBy,ModifiedBy,ModifiedOn,IP")] VehPlatePrefix vehPlatePrefix)
        {
            if (ModelState.IsValid)
            {
                vehPlatePrefix.Status     = AppConstant.Active;
                vehPlatePrefix.CompanyID  = AppConstant.CompanyID;
                vehPlatePrefix.CreatedOn  = DateTime.Now;
                vehPlatePrefix.ModifiedOn = DateTime.Now;
                vehPlatePrefix.IP         = GetIPAddress.getExternalIp();
                _context.Add(vehPlatePrefix);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(vehPlatePrefix));
        }
示例#12
0
        public async Task <IActionResult> Edit([Bind("JobStatId,JobStatName,JobStatCode,Description,Status,CompanyID,CreatedOn,CreatedBy,ModifiedBy,ModifiedOn,IP")] JobStatus jobStatus)
        {
            //if (_context.jobStatus.Any(m => m.Code.Equals(jobStatus.Code)))
            //{
            //    ModelState.AddModelError("", "[" + jobStatus.Code + "]already exists");
            //}

            if (ModelState.IsValid)
            {
                jobStatus.ModifiedOn = DateTime.Now;
                jobStatus.IP         = GetIPAddress.getExternalIp();
                _context.Update(jobStatus);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(jobStatus));
        }
示例#13
0
        public async Task <IActionResult> Create([Bind("CountryId,CountryName,CountryCode,callingCode,Status,CompanyID,CreatedOn,CreatedBy,ModifiedBy,ModifiedOn,IP")] Country country)
        {
            if (_context.country.Any(m => m.CountryCode.Equals(country.CountryCode)))
            {
                ModelState.AddModelError("", "[" + country.CountryCode + "]already exists");
            }
            else if (ModelState.IsValid)
            {
                country.Status     = AppConstant.Active;
                country.CompanyID  = AppConstant.CompanyID;
                country.CreatedOn  = DateTime.Now;
                country.ModifiedOn = DateTime.Now;
                country.IP         = GetIPAddress.getExternalIp();
                _context.Add(country);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(country));
        }
示例#14
0
        public async Task <IActionResult> Create([Bind("VehLicTypeId,VehLicTypeName,VehLicTypeCode,Description,Status,CompanyID,CreatedOn,CreatedBy,ModifiedBy,ModifiedOn,IP")] VehicleLicenceType vehicleLicenceType)
        {
            if (_context.vehicleLicenceType.Any(m => m.VehLicTypeCode.Equals(vehicleLicenceType.VehLicTypeCode)))
            {
                ModelState.AddModelError("", "[" + vehicleLicenceType.VehLicTypeCode + "]already exists");
            }

            else if (ModelState.IsValid)
            {
                vehicleLicenceType.Status     = AppConstant.Active;
                vehicleLicenceType.CompanyID  = AppConstant.CompanyID;
                vehicleLicenceType.CreatedOn  = DateTime.Now;
                vehicleLicenceType.ModifiedOn = DateTime.Now;
                vehicleLicenceType.IP         = GetIPAddress.getExternalIp();
                _context.Add(vehicleLicenceType);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(vehicleLicenceType));
        }
        public async Task <IActionResult> Create([Bind("StateId,StateName,StateCode,CountryId,Status,CompanyID,CreatedOn,CreatedBy,ModifiedBy,ModifiedOn,IP")] State state)
        {
            //if(_context.state.Any(e=>e.StateCode.Equals(state.StateCode)))
            //{
            //    ModelState.AddModelError("", "["+state.StateCode+"] already exist");

            //}
            //else
            if (ModelState.IsValid)
            {
                state.Status     = AppConstant.Active;
                state.CompanyID  = AppConstant.CompanyID;
                state.CreatedOn  = System.DateTime.Now;
                state.ModifiedOn = System.DateTime.Now;
                state.IP         = GetIPAddress.getExternalIp();
                _context.Add(state);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(state));
        }