public IActionResult Create()
        {
            ViewData["CompanyId"]       = new SelectList(_db.Company.GetAll().Where(c => c.IsActive == true && c.IsDeleted == false), "Id", "CompanyName");
            ViewData["SisterConcernId"] = new SelectList(_db.SisterConcern.GetAll().Where(c => c.IsActive == true && c.IsDeleted == false), "Id", "Name");
            //IEnumerable<SisterConcern> sisterConcern = _db.SisterConcern.GetAll();
            vmDivision vmDivision = new vmDivision();

            return(PartialView("_Create", vmDivision));
        }
        public IActionResult Edit(int id)
        {
            ViewData["CompanyId"]       = new SelectList(_db.Company.GetAll().Where(c => c.IsActive == true && c.IsDeleted == false), "Id", "CompanyName");
            ViewData["SisterConcernId"] = new SelectList(_db.SisterConcern.GetAll().Where(c => c.IsActive == true && c.IsDeleted == false), "Id", "Name");

            Division   division   = _db.Division.Get(id);
            vmDivision vmDivision = new vmDivision();

            vmDivision.Id              = division.Id;
            vmDivision.Name            = division.Name;
            vmDivision.SisterConcernId = division.SisterConcernId;
            vmDivision.CompanyId       = division.CompanyId;
            vmDivision.Phone           = division.Phone;
            vmDivision.Email           = division.Email;
            vmDivision.Address         = division.Address;
            return(PartialView("_Edit", vmDivision));
        }
        public IActionResult Edit(vmDivision vmDivision)
        {
            if (ModelState.IsValid)
            {
                Division division = _db.Division.GetFirstOrDefault(c => c.Id == vmDivision.Id);

                division.Name            = vmDivision.Name;
                division.SisterConcernId = vmDivision.SisterConcernId;
                division.CompanyId       = vmDivision.CompanyId;
                division.Phone           = vmDivision.Phone;
                division.Email           = vmDivision.Email;
                division.Address         = vmDivision.Address;

                _db.Division.Update(division);
                _db.Save();
                return(Json(vmDivision));
            }
            return(Json(vmDivision));
        }
 public IActionResult Create(vmDivision vmDivision)
 {
     if (ModelState.IsValid)
     {
         Division division = new Division()
         {
             Name            = vmDivision.Name,
             CompanyId       = vmDivision.CompanyId,
             SisterConcernId = vmDivision.SisterConcernId,
             Address         = vmDivision.Address,
             Email           = vmDivision.Email,
             Phone           = vmDivision.Phone,
             IsActive        = true,
             IsDeleted       = false
         };
         _db.Division.Add(division);
         _db.Save();
         return(Json(division));
     }
     return(Json(vmDivision));
 }