public async Task <ValidationResult <SellerMobile> > AddMobileInStore(SellerMobile sellerMobile) { var validationResult = await MobileAlreadyAssign(sellerMobile.MobileId, sellerMobile.SellerId); if (!validationResult.Succeeded) { _mobileDataService.DeleteById <SellerMobile>(validationResult.Entity.SellerMobileId); } try { var mobiledata = await _mobileDataService.RetrieveAsync <Entity.Mobile>(e => e.MobileId == sellerMobile.MobileId); var mobile = mobiledata.FirstOrDefault(); if (mobile != null) { mobile.IsDeviceInStore = true; await _mobileDataService.UpdateAsync(mobile); } await _dataService.CreateAsync(sellerMobile); validationResult.Entity = sellerMobile; validationResult.Succeeded = true; } catch (Exception ex) { validationResult.Succeeded = false; validationResult.Errors = new List <string> { ex.InnerMessage() }; validationResult.Exception = ex; } return(validationResult); }
public async Task <ActionResult> AssignMobileToSeller(SellerMobile sellerMobile) { var data = await _sellerMobileBusinessService.AddMobileInStore(sellerMobile); return(this.JsonNet(data)); }