コード例 #1
0
ファイル: EventController.cs プロジェクト: punj-aab/School
        public string Create(Event objEvent, string token)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    objEvent.InsertedBy = _userStatistics.UserId;
                    objEvent.InsertedOn = DateTime.Now;
                    if (this.repository.CreateEvent(objEvent))
                    {
                        List<ELetter> objEletterList = this.repository.GetUsersForEvent(objEvent.EventId);
                        ELetter objEletter = null;
                        foreach (var eLetter in objEletterList)
                        {
                            objEletter = new ELetter();
                            objEletter.UserId = eLetter.UserId;
                            objEletter.EventId = eLetter.EventId;
                            objEletter.TemplateId = eLetter.TemplateId;
                            objEletter.OrganizationId = eLetter.OrganizationId;
                            objEletter.InsertedBy = _userStatistics.UserId;
                            this.repository.CreateEletter(objEletter);
                        }
                        SaveFiles(token, this.GetType().Name, objEvent.EventId);
                        return Convert.ToString(true);
                    }
                    return Convert.ToString(false);
                }

                return Convert.ToString(false);
            }
            catch (Exception ex)
            {
                return ex.Message.ToString();
            }
        }
コード例 #2
0
ファイル: CommonRepository.cs プロジェクト: punj-aab/School
        public bool CreateEletter(ELetter objEletter)
        {
            var parameters = new
            {
                UserId = objEletter.UserId,
                EventId = objEletter.EventId,
                TemplateId = objEletter.TemplateId,
                OrganizationId = objEletter.OrganizationId,
                IsRead = false,
                InsertedOn = DateTime.Now,
                InsertedBy = objEletter.InsertedBy
            };

            using (IDbConnection connection = OpenConnection())
            {
                const string storedProcedure = "usp_AddEletters";
                int rowsAffected = connection.Execute(storedProcedure, parameters, commandType: CommandType.StoredProcedure);
                SetIdentity<int>(connection, id => objEletter.EletterId = id);
                if (rowsAffected > 0)
                {
                    return true;
                }
                return false;
            }
        }