public WebResult AddSharing(int ownerId, int friendId, string folder) { WebResult result = new WebResult(); var owner = (from u in db.Users where u.id == ownerId select u).SingleOrDefault(); var friend = (from u in db.Users where u.id == friendId select u).SingleOrDefault(); if (owner == null || friend == null) return new WebResult(WebResult.ErrorCodeList.USER_NOT_FOUND); string path = System.IO.Path.Combine(HttpContext.Current.Server.MapPath("~"), "upload_files", owner.username, folder); if (System.IO.Directory.Exists(path)) { Sharing share = new Sharing() { folder = folder, idOwner = owner.id, idRecevier = friendId, user = owner.username }; db.Sharings.InsertOnSubmit(share); db.SubmitChanges(); } else return new WebResult(WebResult.ErrorCodeList.DIRECTORY_NOT_FOUND); return result; }
partial void UpdateSharing(Sharing instance);
partial void DeleteSharing(Sharing instance);
partial void InsertSharing(Sharing instance);