public Response CreateDocument(Document document) { UserRequest userRequest = new UserRequest(); userRequest.UserID = document.UserID; try { if (_dalUser.GetUserID(userRequest) == ModeUser.Exist) { var data = _dalDoc.CreateDocument(document); DataRow row = data.Tables[0].Rows[0]; var identity = row[0]; int id = (int)identity; return(new ResponseDocumentId() { DocumentId = id }); } return(new ResponseMistakeDetails()); } catch { return(new ResponseErr()); } }
public Response CreateDocument(CreateDocumentRequest request) { try { var id = _idGeneretor.GenerateId(request.OwnerId + request.DocumentName); var ds = _dal.CreateDocument(id, request.OwnerId, request.DocumentName); return(new CreateDocumentResponseOK(id)); } catch (Exception ex) { return(new ResponseError(ex.Message)); } }
public void Test1() { var resolver = new Resolver(); //var dal = resolver.Resolve<IInfraDal>(); IInfraDal dal = new SQLDAL(); //IUserDal u = resolver.Resolve<IUserDal>(); IDocumentDAL u = resolver.Resolve <IDocumentDAL>(); //UserRequest use = new UserRequest() { UserID = "*****@*****.**", UserName = "******" }; u.CreateDocument(new Document() { UserID = "*****@*****.**", ImageURL = "k.png", DocumentName = "image" }); //_paramConverter = new DBParameterConverter(dal); //var con = dal.Connect("Server=(localdb)\\MSSQLLocalDB;Database=Images;" + // "Trusted_Connection=True;"); ////IInfraDal dal = new SQLDAL(); ////IDBParameter p = resolver.Resolve<IDBParameter>(); ////p.ParameterName = "UserID"; ////p.Value = "*****@*****.**"; ////IDBParameter p1 = resolver.Resolve<IDBParameter>(); ////p1.ParameterName = "UserName"; ////p1.Value = "rachel"; ////UserRequest u = new UserRequest() { UserID = "*****@*****.**", UserName = "******" }; //DocumentRequset d = new DocumentRequset() { DocumentName = "new doc", ImageURL = "k.png", UserID = "*****@*****.**" }; //var p = _paramConverter.ConvertToParameter(d, "UserID"); //var p1 = _paramConverter.ConvertToParameter(d, "ImageURL"); //var p2 = _paramConverter.ConvertToParameter(d, "DocumentName"); //dal.ExecSPQuery("CreateDocument", con, p, p1, p2); //var dataset = dal.ExecSPQuery("GetUsers", con); //Console.WriteLine(dataset.Tables[0].Rows.Count); //foreach (DataRow row in dataset.Tables[0].Rows) //{ // Console.WriteLine("{0},{1}", row[0], row[1]); //} }