public HttpResponseMessage Create(DeviceProfileItem item) { try { if (item == null || string.IsNullOrWhiteSpace(item.DeviceId) || string.IsNullOrWhiteSpace(item.IDCard)) { return(base.BuildErrorResult(HttpStatusCode.BadRequest, ErrorCode.ItemNameAndNotesRequired.ToString())); } // Determine if the ID already exists var itemExists = trackingService.DoesItemExist(item.DeviceId); if (itemExists) { return(base.BuildErrorResult(HttpStatusCode.Conflict, ErrorCode.ItemIDInUse.ToString())); } trackingService.InsertData(item); } catch (Exception) { return(base.BuildErrorResult(HttpStatusCode.BadRequest, ErrorCode.CouldNotCreateItem.ToString())); } return(base.BuildSuccessResult(HttpStatusCode.Created)); }
public void Insert(DeviceProfileItem item) { _deviceptofile.Add(item); using (Context.DataClasses_PortalExt dc = new Context.DataClasses_PortalExt()) { dc.Mobile_Device_Profiles.InsertOnSubmit(new Context.Mobile_Device_Profile { IDCard = item.IDCard, DeviceId = item.DeviceId, FullName = item.FullName, MobileNo = item.MobileNo, Email = item.Email, Timestamp = item.Timestamp, Version = item.Version, ShortVersion = item.ShortVersion, CurrentCulture = item.CurrentCulture, IsBackgrounded = item.IsBackgrounded, ScreenHeight = item.ScreenHeight, ScreenWidth = item.ScreenWidth, Manufacturer = item.Manufacturer, Model = item.Model, OperatingSystem = item.OperatingSystem, OperatingSystemVersion = item.OperatingSystemVersion, IsSimulator = item.IsSimulator, IsTablet = item.IsTablet, WhenBatteryPercentageChanged = item.WhenBatteryPercentageChanged, WhenPowerStatusChanged = item.WhenPowerStatusChanged, InternetReachability = item.InternetReachability, CellularNetworkCarrier = item.CellularNetworkCarrier, IpAddress = item.IpAddress, WifiSsid = item.WifiSsid, }); dc.SubmitChanges(); } }
public void InsertData(DeviceProfileItem item) { if (item == null) { throw new ArgumentNullException("item"); } _repository.Insert(item); }