public static int SaveTasks(TasksDbModel Model)
        {
            var outParam = new SqlParameter();

            outParam.ParameterName = "Id";
            outParam.Value         = Model.Id;
            outParam.SqlDbType     = SqlDbType.BigInt;
            outParam.Direction     = ParameterDirection.InputOutput;
            int result = 0;

            using (var Context = new CRMContext())
            {
                Context.Database.ExecuteSqlCommand(
                    "exec dbo.[usp_Sales_Tasks_Save] @Id OUT,@Subject,@Description,@StartDateTime,@EndDateTime," +
                    "@TasksPriorityId,@TasksStatusId,@TasksRelatedTo,@CreatedBy,@IsActive",
                    new Object[]
                {
                    outParam,
                    new SqlParameter("Subject", Model.Subject),
                    new SqlParameter("Description", Model.Description),
                    new SqlParameter("StartDateTime", Model.StartDateTime),
                    new SqlParameter("EndDateTime", Model.EndDateTime),
                    new SqlParameter("TasksPriorityId", Model.TasksPriorityId),
                    new SqlParameter("TasksStatusId", Model.TasksStatusId),
                    new SqlParameter("TasksRelatedTo", Model.TasksRelatedTo),
                    new SqlParameter("CreatedBy", Model.CreatedBy),
                    new SqlParameter("IsActive", Model.IsActive)
                }
                    );
            }
            result = Convert.ToInt32(outParam.Value);
            return(result);
        }
 public static int SaveTaskLinks(TasksDbModel Model)
 {
     using (var Context = new CRMContext())
     {
         return(Context.Database.ExecuteSqlCommand(
                    "exec dbo.[usp_Sales_TaskLinks_Save] @Id,@TaskId,@LinkId,@LinkType",
                    new Object[]
         {
             new SqlParameter("Id", Model.TaskLinkId),
             new SqlParameter("TaskId", Model.Id),
             new SqlParameter("LinkId", Model.LinkId),
             new SqlParameter("LinkType", (int)Model.LinkType)
         }
                    ));
     }
 }