public long AddStoreInventory(AddStoreInventoryModel model) { var sqlQuery = GetStoreInventoryExitsQuery(model.StoreId.ToString(), model.InventoryId.ToString()); var numberOfUnits = GetAvailableUnit(model.StoreId.ToString(), model.InventoryId.ToString()); var count = _db.ExecuteScalar <long>(sqlQuery); if (count > 0) { sqlQuery = ""; sqlQuery = GetEditStoreInventoryQuery(); _db.ExecuteScalar <long>(sqlQuery, new { @numberOfItems = numberOfUnits + model.NumberOfItems, @modifiedBy = _setupUser.GetUserData().Id, @modifiedDate = DateTime.Now, @storeId = model.StoreId.ToString(), @inventoryId = model.InventoryId.ToString() }); return(1); } else { sqlQuery = ""; sqlQuery = GetAddStoreInventoryQuery(); var result = _db.ExecuteScalar <long>(sqlQuery, new { @storeId = model.StoreId.ToString(), @inventoryId = model.InventoryId.ToString(), @numberOfItems = model.NumberOfItems, @createdBy = _setupUser.GetUserData().Id, @createdDate = DateTime.Now, @modifiedBy = _setupUser.GetUserData().Id, @modifiedDate = DateTime.Now }); return(result); } }
public ActionResult Accept(InvitationModel model) { try { var user = _setupUser.GetUserData(); if (ModelState.IsValid) { _employeeService.SendInvitation(model, user.Id); return(View().WithSuccess("En aktiveringslänk har sänts till din emailadress.")); } else { return(View()); } } catch (Exception ex) { _log.ErrorFormat("Error in requesting employee. Error : {0}", ex.Message); _log.Error(ex); return(RedirectToAction("Accept").WithError(ex.Message)); } }