// GET : DeviceType/Add
 public ActionResult Add(string deviceId)
 {
     DeviceTypeViewModel deviceVM = new DeviceTypeViewModel();
     if(string.IsNullOrWhiteSpace(deviceId))
     {
         deviceVM.DeviceTypeId = Guid.Empty;
     }
     else
     {
         var dealerGuid = Guid.Parse(deviceId);
         DeviceType deviceType = devicetypeService.GetDeviceType(dealerGuid);
         deviceVM = Mapper.Map<DeviceType, DeviceTypeViewModel>(deviceType);
     }
     return PartialView("_Add", deviceVM);
 }
        public ActionResult Add(DeviceTypeViewModel  deviceType)
        {
            if (Session["UserData"] is Admin)
            {
                if (ModelState.IsValid)
                {
                    try
                    {
                        if (deviceType.DeviceTypeId == Guid.Empty)
                        {
                            deviceType.DeviceTypeId = Guid.NewGuid();
                            var device = Mapper.Map<DeviceTypeViewModel, DeviceType>(deviceType);
                            //     deal.parent = Guid.Parse(Request.Form["CustomerId"]);
                            devicetypeService.CreateDeviceType(device);
                            devicetypeService.SaveDeviceType();

                        }
                        else
                        {
                            var device = devicetypeService.GetDeviceType(deviceType.DeviceTypeId);
                            Mapper.Map<DeviceTypeViewModel, DeviceType>(deviceType, device);
                            devicetypeService.UpdateDeviceType(device);
                            devicetypeService.SaveDeviceType();

                        }

                        return Json(new { Result = "Success" });
                    }
                    catch (Exception ex)
                    {

                    }
                }
            }
            return PartialView("_Add", deviceType);
        }