예제 #1
0
 public ActionResult Create()
 {
     Template objTemplate = new Template();
     SelectList organizationList = null;
     SelectList templateTypeList = null;
     LoadSelectLists(out organizationList, out templateTypeList);
     objTemplate.OrganizationList = organizationList;
     objTemplate.TemplateTypeList = templateTypeList;
     objTemplate.OrganizationId = ViewBag.OrganizationId == null ? 0 : Convert.ToInt32(ViewBag.OrganizationId);
     return PartialView(objTemplate);
 }
예제 #2
0
 public string Create(Template objTemplate)
 {
     try
     {
         if (ModelState.IsValid)
         {
             objTemplate.InsertedOn = DateTime.Now;
             objTemplate.InsertedBy = _userStatistics.UserId;
             if (repository.CreateTemplate(objTemplate))
             {
                 return Convert.ToString(true);
             }
             return Convert.ToString(false);
         }
         return Convert.ToString(false);
     }
     catch (Exception ex)
     {
         return ex.Message.ToString();
     }
 }
예제 #3
0
 public bool CreateTemplate(Template objTemplate)
 {
     var parameters = new
     {
         Name = objTemplate.Name,
         Description = objTemplate.Description,
         TemplateText = objTemplate.TemplateText,
         IsActive = objTemplate.IsActive,
         InsertedOn = objTemplate.InsertedOn,
         InsertedBy = objTemplate.InsertedBy,
         OrganizationId = objTemplate.OrganizationId,
         TemplateTypeId = objTemplate.TemplateTypeId
     };
     using (IDbConnection connection = OpenConnection())
     {
         const string storedProcedure = "usp_AddTemplates";
         int rowsAffected = connection.Execute(storedProcedure, parameters, commandType: CommandType.StoredProcedure);
         SetIdentity<int>(connection, id => objTemplate.TemplateId = id);
         if (rowsAffected > 0)
         {
             return true;
         }
         return false;
     }
 }