public async Task <ShareDto> ShareContentForUserIdAsync(ShareDto shareDto, Guid userId) { var shareKey = CreateShareKey(); shareDto.ShareUrl = ShareKeyPrefix + shareKey; var shareModel = new Share { Id = Guid.NewGuid(), ShareKey = shareKey, SharingUserId = userId, ValidFromTime = shareDto.ValidFromTime, ValidUntilTime = shareDto.ValidUntilTime, Email = shareDto.Email, AllowActivities = shareDto.AllowActivities, AllowDocuments = shareDto.AllowDocuments, AllowDiseases = shareDto.AllowDiseases, AllowAcuteDiseases = shareDto.AllowAcuteDiseases, AllowComments = shareDto.AllowComments, AllowCommentsWrite = shareDto.AllowCommentsWrite }; await shareRepository.InsertAsync(shareModel); return(shareDto); }
public ShareDto Create(ShareDto dto) { var share = Mapper.Map <ShareDto, Share>(dto); _shareRepository.Create(share); return(Mapper.Map <Share, ShareDto>(_shareRepository.FindById(share.Id))); }
public void ValidatePostModel(ShareDto dto) { if (dto.Turbine != null && dto.Farm != null) { throw new Exception(_exceptionMsgShareShouldBelongToTurbineOrFarm); } ValidatePrice(dto.Price); if (dto.PurchaseDate == DateTime.MinValue) { dto.PurchaseDate = DateTime.Now; } }
public ResultInfo SaveShare(ShareDto dto) { ResultInfo r = new ResultInfo(); if (dto.ID == Guid.Empty) { dto.CreatedAt = DateTime.Now; dto.ID = Guid.NewGuid(); dto.IsDel = false; dto.IsReaded = false; if (string.IsNullOrEmpty(dto.Title) || dto.Sender == Guid.Empty) { r.IsSuccess = false; r.Message = "参数空异常"; return(r); } if (!string.IsNullOrEmpty(dto.Description)) { dto.Abstract = dto.Description.Substring(0, System.Math.Min(dto.Description.Length, 1000)).GetTxtFromHtml2().Replace(" ", ""); } string inserttab = @"insert into huangguan_share(ID,Title,Description,Sender,Label,CreatedAt,IsDel,IsReaded,Abstract) values('{0}',N'{1}',N'{2}','{3}',N'{4}','{5}',{6},{7},N'{8}')" .FormatStr(dto.ID, dto.Title, dto.Description, dto.Sender, dto.Label, dto.CreatedAt, 0, 0, dto.Abstract); int rowcount = MySqlDbHelper.ExecuteSql(connCommonsStr, inserttab); r.IsSuccess = true; r.Message = dto.ID.ToString(); return(r); } else { string selsql = @"select ID from huangguan_share where ID='{0}'".FormatStr(dto.ID); DataTable dt = MySqlDbHelper.ExecuteQuery(connCommonsStr, selsql); if (dt.Rows.Count <= 0) { r.IsSuccess = false; r.Message = "分享主题信息为空异常"; return(r); } if (!string.IsNullOrEmpty(dto.Description)) { dto.Abstract = dto.Description.Substring(0, System.Math.Min(dto.Description.Length, 1000)).GetTxtFromHtml2().Replace(" ", ""); } string updatesql = @"update huangguan_share set Description=N'{0}',Label=N'{1}',Title=N'{2}',Abstract=N'{3}' where ID='{4}'".FormatStr(dto.Description, dto.Label, dto.Title, dto.Abstract, dto.ID); int cccc = MySqlDbHelper.ExecuteSql(connCommonsStr, updatesql); r.IsSuccess = true; r.Message = dto.ID.ToString(); return(r); } }
public IActionResult Share([FromBody] ShareDto shareDto) { _logger.LogInformation("Sharing application: " + shareDto.ApplicationId + " with " + shareDto.Email); try { var s = _applicationService.Share(shareDto.UserId, shareDto.ApplicationId, shareDto.Email); return(Ok(shareDto)); } catch (AppException ex) { // return error message if there was an exception return(BadRequest(new { message = ex.Message })); } }
public async Task <IActionResult> ShareContact([FromBody] ShareDto shareDto) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var userEmail = HttpContextHelpers.GetCurrentUserEmail(User); var user = await _userService.FindByEmailAsync(userEmail); var shareKardCommand = new ShareContactCommand(shareDto.ContactId, shareDto.RecipientUserId, user.Id); await _commandBus.Send(shareKardCommand); return(Ok()); }
public async Task <ActionResult> CreateShare([FromBody] ShareDto shareDto) { var result = await shareInteractor.ShareContentForUserIdAsync(shareDto, currentUserInformation.UserId); return(Ok(result)); }
public QueryResult <ShareDto> GetShare(Guid?usrId, string titlelabel, int?type, int page, int pagesize) { QueryResult <ShareDto> r = new QueryResult <ShareDto>(); kuerhotelsEntities m = new kuerhotelsEntities(); var q = from s in m.huangguan_share where s.IsDel == false orderby s.CreatedAt descending select new ShareDto { CreatedAt = s.CreatedAt, Abstract = s.Abstract, //Description = s.Description, ID = s.ID, Label = s.Label, Sender = s.Sender, Title = s.Title, }; Dictionary <Guid?, bool?> shareIdDatas = new Dictionary <Guid?, bool?>(); List <Guid?> shareIds = new List <Guid?>(); if (type == 2) { string sql1 = @"select s.Id, s.Title, s.Sender, s.Label, s.CreatedAt, s.IsDel, su.IsReaded, s.Abstract,su.ShareId from huangguan_share s join huangguan_shareusers su on s.Id = su.ShareId where 1=1 and (s.IsDel = 0 and su.SharedUser = {0}) order by s.CreatedAt desc".FormatStr(usrId); DataTable dt1 = MySqlDbHelper.ExecuteQuery(connCommonsStr, sql1); List <ShareDto> list1 = new List <ShareDto>(); foreach (DataRow item in dt1.Rows) { ShareDto sd = new ShareDto(); sd.CreatedAt = Convert.ToDateTime(item["CreatedAt"].ToString()); sd.Abstract = item["Abstract"].ToString(); sd.ID = Guid.Parse(item["Id"].ToString()); sd.Label = item["Label"].ToString(); sd.Sender = Guid.Parse(item["Sender"].ToString()); sd.Title = item["Title"].ToString(); sd.IsReaded = bool.Parse(item["IsReaded"].ToString()); sd.ShareId = Guid.Parse(item["ShareId"].ToString()); list1.Add(sd); } q = list1.AsQueryable(); } else if (type == 3) { string selsql = @"select s.Id, s.Title, s.Sender, s.Label, s.CreatedAt, s.IsDel, s.Abstract from huangguan_share s where 1=1 and s.IsDel = 0 order by s.CreatedAt desc".FormatStr(usrId, usrId); DataTable dt = MySqlDbHelper.ExecuteQuery(connCommonsStr, selsql); List <ShareDto> list2 = new List <ShareDto>(); foreach (DataRow item in dt.Rows) { ShareDto sd = new ShareDto(); sd.CreatedAt = Convert.ToDateTime(item["CreatedAt"].ToString()); //Description = s.Description, sd.Abstract = item["Abstract"].ToString(); sd.ID = Guid.Parse(item["Id"].ToString()); sd.Label = item["Label"].ToString(); sd.Sender = Guid.Parse(item["Sender"].ToString()); sd.Title = item["Title"].ToString(); list2.Add(sd); } q = list2.AsQueryable(); } else if (type == 1) { if (usrId != Guid.Empty) { q = q.Where(x => x.Sender == usrId); r.Count = q.ToList().Count; r.Result = q.ToList(); return(r); } } else if (!type.HasValue) { shareIdDatas = m.huangguan_shareusers.Where(x => x.SharedUser == usrId).ToDictionary(x => x.ShareId, y => y.IsReaded); shareIds = shareIdDatas.Keys.ToList(); if (shareIds.Count > 0) { q = q.Where(x => shareIds.Contains(x.ID) || x.Sender == usrId); } } if (!string.IsNullOrEmpty(titlelabel)) { q = q.Where(x => x.Title.Contains(titlelabel) || x.Label.Contains(titlelabel)); } if (q.ToList().Count > 0) { var List = q.ToList(); foreach (var item in List) { if (item.Sender != Guid.Empty) { string touxing = "select LoginName,NickName,HeadIcon,Gender from huangguan_user where ID='{0}'".FormatStr(item.Sender); var dataicon = MySqlDbHelper.ExecuteQuery(connCommonsStr, touxing); if (dataicon.Rows.Count <= 0) { return(r); } item.SenderName = string.IsNullOrEmpty(dataicon.Rows[0]["NickName"].ToString()) ? "无昵称" : dataicon.Rows[0]["NickName"].ToString(); item.SenderHead = dataicon.Rows[0]["HeadIcon"].ToString(); item.SenderGender = dataicon.Rows[0]["Gender"].ToString(); string RCount = "select * from huangguan_sharereply where IsDel = 0 and ShareId = '{0}'".FormatStr(item.ID); string LCount = "select * from huangguan_sharereply where ` Love` = 1 and ShareId = '{0}'".FormatStr(item.ID); item.ReplyerCount = MySqlDbHelper.ExecuteQuery(connCommonsStr, RCount).Rows.Count; item.LoveCount = MySqlDbHelper.ExecuteQuery(connCommonsStr, LCount).Rows.Count; } } r.Count = List.Count(); r.Result = List.Skip(page * pagesize).Take(pagesize).ToList(); return(r); } else { r.Count = 0; r.Result = q.ToList(); return(r); } }
public ActionResult <ShareDto> Post([FromBody] ShareDto dto) { _shareService.ValidatePostModel(dto); return(_shareService.Create(dto)); }